MYSQL AND OR条件有关问题

WBOY
Release: 2016-06-13 12:16:36
Original
949 people have browsed it

MYSQL AND OR条件问题

<br />SELECT id,name		<br />FROM test <br />WHERE type_1 = 1 OR type_2 = 1 AND id = 1<br />
Copy after login

这样会印出全部,无视了id=1这个条件,要怎么改才对呢?
------解决思路----------------------
SELECT id,name       <br />FROM test <br />WHERE (type_1 = 1 OR type_2 = 1) AND id = 1
Copy after login
Copy after login

SELECT id,name       <br />FROM test <br />WHERE type_1 = 1 OR (type_2 = 1 AND id = 1)
Copy after login

SELECT id,name       <br />FROM test <br />WHERE (type_1 = 1 OR type_2 = 1) AND id = 1
Copy after login
Copy after login

要看你的实际需要

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template