by
4,027 19
1
5
2,382
0
Top 1% !
Famous
Easy-to-find
Specified
OpenSource
Popularity: 7660th place

Published on:

DBMSMySQL
Languagemysql
LicenseMIT_X11

SQL query SELECT * WHERE clause AND / OR  compare conditionally

Compare multiple values in a WHERE condition.
Test that both conditions are true using the AND keyword, alternatively whether either conditions are true using the OR keyword.
Copy Embed Code
<iframe id="embedFrame" style="width:600px; height:300px;"
src="https://www.snip2code.com/Embed/1171046/SQL-query-SELECT---WHERE-clause-AND---OR?startLine=0"></iframe>
Click on the embed code to copy it into your clipboard Width Height
Leave empty to retrieve all the content Start End
SELECT <columns> FROM <table> WHERE <condition 1> AND <condition 2> ...; SELECT <columns> FROM <table> WHERE <condition 1> OR <condition 2> ...; //Examples: SELECT username FROM users WHERE last_name = "Kong" AND first_name = "King"; SELECT * FROM products WHERE category = "Insects" AND price < 100; SELECT * FROM movies WHERE title = "The Matrix" OR title = "The Blues Brothers" OR title = "2 IDs 1 Row"; SELECT country FROM countries WHERE population < 3 OR population > 1;
If you want to be updated about similar snippets, Sign in and follow our Channels

blog comments powered by Disqus