我有一个选择声明:
SELECT term.name FROM terms as TERM WHERE term.name LIKE ''
现在,我有一个表选项,其中我有一个列options_name,其值为= trgovine_TERMID_lokacija
因此,例如,我需要编写将使用术语连接选项表的sql语句,并将使用当前id搜索列options_name。
我试过这个:
SELECT term.id, term.name FROM terms as term JOIN options AS o ON (o.option_name = trgovine_term.id_lokacija) WHERE term.name LIKE ''
但它不起作用:(
更新:
我现在甚至都试过这个:
SELECT term.term_id, term.name FROM wp_terms as term INNER JOIN wp_options AS o ON o.option_name = 'trgovine_'+term.term_id+'_lokacija' WHERE term.name LIKE '%%adidas%%'
答案 0 :(得分:0)
SELECT term.id, term.name FROM terms as term INNER JOIN options AS o ON o.option_name = 'trgovine_TERMID_lokacija' WHERE term.name LIKE ''
答案 1 :(得分:0)
我找到了正确的答案。这是将数据合并到字符串中的正确方法。 CONCAT FTW! :)
o.option_name = CONCAT('trgovine_', term.term_id, '_lokacija')