[英]one column as a substring of another column
I have 3 tables, as table-a, table-b and table-c. 我有3个表,分别是表a,表b和表c。 I have stuck with a problem where I have substring, say XYZ, present in column-1 of table-a, whereas in table-b i have some rows with XYZ as a substring in one of the column.
我遇到了一个问题,即我在表a的第1列中存在子字符串(例如XYZ),而在表b中,我在其中一列中有一些行以XYZ作为子字符串。 I want to fetch all those rows from both of the tables, table-a as well as table-b, where I have one of the column from table-c='123'(eg)
我想从两个表中获取所有这些行,表a和表b,其中我有一个来自表c ='123'的列(例如)
Below is my query: 以下是我的查询:
SELECT DISTINCT a.column-1, b.column-2
FROM table-a a, table-b b, table-c c
WHERE c.column='123' AND a.column-1=b.column-2;
With this query it is printing rows from table-b where only XYZ present but not %XYZ%. 通过此查询,它正在打印表b中的行,其中仅存在XYZ而没有%XYZ%。
Thanks in advance for co-operation.. 预先感谢您的合作。
我认为您要寻找的条件是:
AND b.column-2 LIKE CONCAT('%', a.column-1, '%')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.