1

我有一个选择语句:

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%%'
4

2 回答 2

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 ''
于 2013-09-11T12:30:51.657 回答
0

我找到了正确的答案。这是将数据合并为字符串的正确方法。CONCAT FTW!:)

o.option_name = CONCAT('trgovine_', term.term_id, '_lokacija')
于 2013-09-13T08:35:40.347 回答