Search
 
SCRIPT & CODE EXAMPLE
 

SQL

element is equal one of values sql server

Put parentheses around the "OR"s:
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 = 2
    OR ads.county_id = 5
    OR ads.county_id = 7
    OR ads.county_id = 9
)

Or even better, use IN:

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)
Comment

PREVIOUS NEXT
Code Example
Sql :: sqlite closes value 
Sql :: sql include rows with 0 values 
Sql :: sql date time query find 
Sql :: sql server 2016 iso 
Sql :: install package for sqlserver in asp.net core 
Sql :: provide hardcoded value in the mysql query 
Sql :: plsql regex match whole word 
Sql :: flask sqlalchemy single table inheritance 
Sql :: get similar records in sql for a special number 
Sql :: <sql:datasource var="Snapsho" 
Sql :: oracle winter time change 
Sql :: sqlite headers 
Sql :: postgresql inline table 
Sql :: how to merge to coloumns into a single column with a space. 
Sql :: how to drop mili second in sql 
Sql :: tabular function in sql server 
Sql :: add sql file to seeder 
Sql :: insert thai language sql server 
Sql :: sql filter rows with condition 
Sql :: what to do if foreign key is making conflict while deleting record from sql table using c# 
Sql :: sqlalchemy sequence postgresql 
Sql :: sql queries questions 
Sql :: psql database does not exist 
Sql :: convert sql query to laravel eloquent 
Sql :: backup table mssql 
Sql :: module operator in oracle sql 
Sql :: jooq finding lastest value in table 
Csharp :: how to write hello world in c# 
Csharp :: loop over object properties c# 
Csharp :: c sharp split by newline 
ADD CONTENT
Topic
Content
Source link
Name
3+1 =