如何将列名组合成MySQL“LIKE”子句

时间:2013-10-08 11:28:39

标签: mysql sql database

我想加入两个表t1t2,以便t2中的列值为any valid string including null followed by a value in column of t table

我想要类似的东西:

SELECT * FROM t_cities c JOIN temp_table t ON c.NAME LIKE "%t.token"但不知道确切的sytax。上述陈述当然会出错。

2 个答案:

答案 0 :(得分:8)

尝试此查询,它应该可以。

SELECT * FROM t_cities as a  
JOIN temp_table as b  
ON a.NAME   LIKE concat("%",b.token);

注意 - 此查询不会像普通加入一样快,需要时间。

答案 1 :(得分:0)

    SELECT *
  FROM t_cities c
  JOIN temp_table t ON c.field = t.field
 where c.NAME LIKE "%t.token"
相关问题