[英]SQL Insert from another table
I can use some help with a sql INSERT. 我可以在sql插入中使用一些帮助。
words_table contains productid word product table contains productid description
I'd like to create a row in words_table that contains the productid and the word "foundit" for each row in product table WHERE description LIKE '%keyword%'. 我想在word_table中创建一行,其中包含productid和“%keyword%”这样的产品表中每一行的productid和单词“ foundit”。
and I'm not sure how to do it. 我不确定该怎么做。
Thanks 谢谢
Try this: 尝试这个:
INSERT INTO words_table (productId, word)
SELECT productId, 'foundit'
FROM product
WHERE description like '%keyword%'
INSERT INTO Words_table
SELECT ProductId, 'FoundIt'
FROM Product
WHERE Description LIKE '%keyword%'
INSERT words_table (productid, word)
SELECT productid, 'foundit'
FROM product
WHERE description LIKE '%' + @keyword + '%'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.