Link to home
Start Free TrialLog in
Avatar of mar2195
mar2195

asked on

MySQL Query instead of PHP If/Else

SITUATION:
After the user has selected the country "US" - they are then going to select a state (Example; NY) and SUBMIT - DB / PHP displays output.

I need either PHP or MySQL to parse out only the records that qualify: US + NY

Here is the Country query that I'm using:
SELECT * FROM dealers WHERE Country = 'US'

Open in new window

table: dealers
columns:
id
Dealer
Phone
City
State
Country

Obviously, I could use a php IF/ELSE to only display the selected State records.

Instead, I'm hoping there's a way to edit the query listed above to handle this.

Yes, I am a MySQL newbie.


Thanks.
Avatar of santoshmotwani
santoshmotwani
Flag of Australia image

This will display records with US + NY

SELECT * FROM dealers WHERE Country = 'US' and City = 'NY'
ASKER CERTIFIED SOLUTION
Avatar of hielo
hielo
Flag of Wallis and Futuna image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mar2195
mar2195

ASKER

@santoshmotwani  ... thanks also.

FYI:  The BACKTICKS are not always necessary (at least in the testing that I completed).
sorry i must be sleeping when i wrote above query  totally forgot NY is a state
Avatar of mar2195

ASKER

lol  ... it's a CITY also!