如何使用"包括" SQL中的功能?

时间:2017-01-16 06:37:33

标签: sql

我需要以下功能,如何在查询中构建它?

Select * 
from table 
where column 4 includes column3

实施例: 请查找表格截图的附件。

Table structure

我想提取第4列包含第3列的所有行。

3 个答案:

答案 0 :(得分:0)

Select * from table where column4=column3

答案 1 :(得分:0)

使用带有column3

中“value”的LIKE语句
select *
from the_table
where column4 like '%'||column3||'%'

||是字符串连接的ANSI SQL运算符,但并非所有DBMS都尊重它。

答案 2 :(得分:0)

我可能会使用字符串查找函数或类似的东西,并且当我看到这被标记为Mysql时,您应该能够使用LOCATE

SELECT
    *
FROM
    table
WHERE
    LOCATE(column3, column4) > 0