GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   What type of MYSQL JOIN do I need (https://gfy.com/showthread.php?t=1050145)

eMonk 12-16-2011 12:59 PM

What type of MYSQL JOIN do I need
 
My old query was:

Code:

$query = "SELECT city_name FROM city WHERE province_id = 9";
Now I'm using:

$city = $_GET['city'];

and just have the city name now but need to fetch all the cities in the province that $city is in.

Here are my tables:

Code:

Table: city
column: city_name = Vancouver, Victoria, Edmonton
column: province_id = 9, 9, 8

Table: province
column: id = 8, 9
column: name = Calgary, British Columbia

So if $city is in province British Columbia, what type of join to I need to fetch all cities listed in British Columbia?

nm_ 12-16-2011 01:41 PM

SELECT city_name FROM city WHERE province_id IN (SELECT province_id FROM city WHERE city_name = $city) ???

eMonk 12-16-2011 02:01 PM

That worked thanks!

Adult Insider Dave 12-16-2011 03:41 PM

If you ever need major coding help contact me anytime!


All times are GMT -7. The time now is 12:39 PM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123