使用mysql select查询显示结果行

3phpmpom  于 2021-06-25  发布在  Mysql
关注(0)|答案(3)|浏览(303)

我试图选择status=y的行,但mysql也显示status=n和y的所有数据。我只想显示status=y的数据。
以下是我的mysql查询:

select * from table where status='Y' and keywords like '%cook%' OR category like '%cook%' OR product_name like '%cook%'

如何显示status=y的数据。

u2nhd7ah

u2nhd7ah1#

按以下方式尝试

select * from table where status='Y' and (keywords like '%cook%' OR category like '%cook%' OR product_name like '%cook%')
xyhw6mcr

xyhw6mcr2#

试试这个

SELECT * FROM `table` WHERE 
`status`='Y' AND 
(keywords LIKE '%cook%' OR category LIKE '%cook%' OR product_name LIKE '%cook%')
ajsxfq5m

ajsxfq5m3#

你需要把你的工作分组 or 标准使用 (...) ```
select * from table
where status='Y'
and (keywords like '%cook%'
or category like '%cook%'
or product_name like '%cook%')

相关问题