您好,欢迎访问一九零五行业门户网

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

要看你的实际需要
其它类似信息

推荐信息