I have a VERY basic database that i need to return certain results for.
The table i’m searching is called Judge and it contains the columns:
Judge_id, Name, Suburb
In my select statement I need to return the results of everyone who lives in Adelaide and Sydney.
So I use:
SELECT *
FROM judge
WHERE Suburb LIKE ('Adelaide' 'Sydney');
but this returns no results. Also tried:
SELECT *
FROM judge
WHERE Suburb = 'Adelaide' 'Sydney'
Still no results.
If I only search for just Adelaide however:
SELECT *
FROM judge
WHERE Suburb = 'Adelaide'
I get ONE result. However there are multiple matches, and the result that is returned in the last one on the table (if that has anything to do with it).
If I do:
SELECT *
FROM judge
WHERE Suburb LIKE '%Adelaide%'
I get both matches. But if i leave the % signs out, I only get the one match again.
If i do a search for any of the “Name”s of the people in the table, i can get matches back for any of them fine. So why am i having trouble getting a match for Suburb?
Thanks for any help
EDIT:
Table looks like:
CREATE TABLE JUDGE (
Judge_id INT NOT NULL,
Name VARCHAR(25),
Address VARCHAR(25),
PRIMARY KEY (Judge_id)
);
and data:
1 Smith Melbourne
2 Green Cootamundra
3 Gates Dunkeld
4 Smith Sydney
5 Russell Adlaide
6 Schofield Adelaide
I agree with Ravi’s suggestion – but if you really do want to use “LIKE” then use:
Only of any use if there are suffixes to that field data though.