[英]check if value of column 2 contains in column 1 in sql
I am trying to check if fav column from table2 contains the value of the property column.我正在尝试检查 table2 中的 fav 列是否包含属性列的值。
here is my query这是我的查询
SELECT name, title, property FROM table2, table1 where property like'%'+(select fav from table2 where name = 'pritam')+'%'
but this returns 0 rows但这会返回 0 行
I think you intend to use an explicit join here:我认为您打算在这里使用显式联接:
SELECT name, title, property
FROM table2 t2
INNER JOIN table1 t1
ON INSTR(property, fav) > 0
WHERE
name = 'pritam';
Note that you should always try to use table aliases whenever possible.请注意,您应该尽可能尝试使用表别名。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.