mercredi 21 octobre 2020

If Column1 = X, Get Value of Column2 (say it's Y), Then Return All Rows Where Column2 = Y

I know very basic SQL, but my brain is making this overly complicated.

In short, let's say I've got two columns, Column1 is CLIENT_NAME, and Column2 is CLIENT_CITY. If CLIENT_NAME = "Stewie Griffin" and CLIENT_CITY = "Quahog", I return all lines where CLIENT_CITY = "Quahog" (regardless of CLIENT_NAME).

But it's not as simple as [WHERE CLIENT_NAME = 'Stewie Griffin' AND CLIENT_CITY = 'Quahog'] because CLIENT_CITY is technically a variable. My queries are based on one client at a time, so I will only have a [WHERE CLIENT_NAME = 'Stewie Griffin'], then the query will have to return the CLIENT_CITY (or CITIES).

Thank you!!

Aucun commentaire:

Enregistrer un commentaire