sql select where multiple values code example

Example 1: sql where multiple values

SELECT column_name(s)
FROM table_name
WHERE column_name IN (value1, value2, ...);

Example 2: sql field equals multiple values

SELECT ads.*, location.county 
FROM ads
LEFT JOIN location ON location.county = ads.county_id
WHERE ads.published = 1 
AND ads.type = 13
AND ads.county_id IN (2, 5, 7, 9)

Example 3: in condition in sql

IN condition allows you to easily test
if an expression matches any value
in a list of values.
It is for reducing  multiple OR
conditions in a SELECT, INSERT, 
UPDATE, or DELETE statement.

Tags:

Sql Example