首頁 >後端開發 >php教程 >MYSQL AND OR条件问题

MYSQL AND OR条件问题

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB原創
2016-06-23 13:38:191125瀏覽


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

要看你的实际需要

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn