Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

New to SQL – Matching two columns in one query

I was hoping someone could help me.
I have a list of addresses of businesses and the owners addresses. I need to write a query that tells me how many owners live in the same area as their restaurants . I’m a newbie at this so apologies if I havent explained that properly.

I have this but have now hit a brick wall:
SELECT (*) address FROM businesses WHERE owner_zip = Same

Could anyone help please?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Thank you

>Solution :

the following sql query will say how many records in the table BUSINESSES have same values for the columns OWNER_ZIP and BUSINESS_ZIP (I had to invent that column because you didn’t say):

SELECT COUNT(*) FROM BUSINESSES WHERE OWNER_ZIP = BUSINESS_ZIP
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading