Home > Software design >  New to SQL - Matching two columns in one query
New to SQL - Matching two columns in one query

Time:04-06

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?

Thank you

CodePudding user response:

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
  • Related