Home > Database > Mysql Tutorial > body text

mysql 如何把查询到的结果插入到另一个表中

WBOY
Release: 2016-06-06 09:41:44
Original
2349 people have browsed it

mysql查询插入新表

首先我们在goods表中查询
SELECT goods_id FROM ecs_goods WHERE goods_name = '23423423' LIMIT 1
查询goods_name对应的goods_id的值
然后把查询到的goods_id的值作为参数,
INSERT INTO ecs_comment (comment_id, comment_type, id_value, email, user_name, content, comment_rank, add_time, ip_address, status, parent_id, user_id) VALUES (NULL, '0', 'goods_id', 'asdas', 'asdas', '23324324', '0', '2015-04-05 19:55:05', '', '1', '0', '0');
插入到另一个表中的新记录里
插入语句中的goods_id的值就是上面查询语句中的goods_id的值

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!