查询使用同一列中的多个LIKE?

Mel*_*Dog 2 sql mysqli

我的数据库列出了Jobs.我希望用户能够查询来自特定行业的作业,但是可以根据需要从type列中选择尽可能多的工作类型,例如:

SELECT * FROM `rec_jobs` 
WHERE `industry` LIKE '%Security%' AND 
   (`type` LIKE '%Full-Time%' OR 'type' LIKE '%Part-Time%' OR 'type' LIKE '%Casual%' OR 'type' LIKE '%Contract%');
Run Code Online (Sandbox Code Playgroud)

这应该返回如下:

ID - Industy - Type


1 - 安全 - 兼职

2 - 安全 - 全职

3 - 安全 - 休闲

4 - 安全 - 全职

等等

但它没有按预期工作 - 我没有得到任何SQL错误或任何结果(虽然我知道行存在).

有谁知道更好的方法来实现这一点(或在谷歌搜索的正确术语)?

Jen*_*ens 5

你应该在列名类型周围使用相同的引号:

SELECT *
FROM `rec_jobs`
WHERE `industry` LIKE '%Security%'
    AND (
        `type` LIKE '%Full-Time%'
        OR `type` LIKE '%Part-Time%'
        OR `type` LIKE '%Casual%'
        OR `type` LIKE '%Contract%');
Run Code Online (Sandbox Code Playgroud)