user4045186
user4045186

Reputation:

sql LIKE statement combined from three "like"`s

how to combine sql query from three like statements? I`m trying like this:

SELECT * FROM myTable 
WHERE 
  (NAME LIKE '%someChars%' AND 
    (CITY LIKE '%someChars%' AND 
     TYPE LIKE'% someChars%')
  );

It doesn`t work, can you help me with that please ?

Upvotes: 0

Views: 132

Answers (2)

Swift
Swift

Reputation: 1881

The query is correct except the fact that Type is a sql keyword, so try putting it between bracket like that:

SELECT * FROM [myTable] 
 WHERE ([NAME] LIKE '%someChars%' AND
        ([CITY] LIKE '%someChars%' AND
         [TYPE] LIKE '%someChars%'));

PS: The parenthesis are not needed

Upvotes: 1

thiagobraga
thiagobraga

Reputation: 1561

SELECT *
FROM myTable
WHERE
  NAME LIKE '%someChars%' AND
  CITY LIKE '%someChars%' AND
  TYPE LIKE '%someChars%';

Upvotes: 0

Related Questions