您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

MYSQL AND OR条件有关问题

2026/1/30 17:42:50发布27次查看
mysql and or条件问题
select id,name
from test
where type_1 = 1 or type_2 = 1 and id = 1

这样会印出全部,无视了id=1这个条件,要怎么改才对呢?
------解决思路----------------------
select id,name
from test
where (type_1 = 1 or type_2 = 1) and id = 1

select id,name
from test
where type_1 = 1 or (type_2 = 1 and id = 1)
select id,name
from test
where (type_1 = 1 or type_2 = 1) and id = 1

要看你的实际需要
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product