[英]Mysql search table with value from different table
Basically I have 2 different tables one for Items and another for a Search. 基本上,我有2个不同的表,一个用于项,另一个用于搜索。
I want to be able to put in a word in the search table and have it be used with my items table to find any entries that match the search word. 我希望能够在搜索表中输入一个词,并将其与我的项目表一起使用,以查找与搜索词匹配的所有条目。
How can I set it up to do it exactly this way? 我如何设置它完全按照这种方式进行?
SELECT * FROM [Items] WHERE ItemName LIKE '%keyword%'
How can I replace the '%keyword%'
with the word that is in the Search table? 如何用
'%keyword%'
搜索”表中的单词替换'%keyword%'
?
Try this 尝试这个
SELECT * FROM Items i
LEFT JOIN search s
ON s.items.id = i.itemid
WHERE i.ItemName AND s.ItemName LIKE '%keyword%'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.