I've got this table:
CREATE TABLE clients (
id BIGSERIAL NOT NULL,
company CHARACTER VARYING(255) DEFAULT '' NOT NULL,
email CHARACTER VARYING(50) DEFAULT '' NOT NULL,
city CHARACTER VARYING(80),
postcode CHARACTER VARYING(20),
);
I got a list of cities and postcode. I need to find if any row matches with the data I have:
City,Zipcode
Lansdowne,2163
Villawood,2163
Smithfield,2164
I'm using this query; how can I achieve the expected result?
SELECT
t1.id,
t1.city,
t1.company,
t1.postcode
FROM
clients t1
LEFT JOIN
clients t2 ON t2.city = t1.city
LEFT JOIN
clients t3 ON t3.postcode = t1.postcode
WHERE t2.city IN ('Lansdowne','Villawood','Smithfield',)
AND t3.postcode IN ('2164','2163','2163',)
Would the query be right?