Jump to content

Questions about doing an inner join


skallsen

Recommended Posts

Hi all! I'm developing my new site and having trouble with getting an inner join to work with PHP/MySql.

I have an inner join that DOES work and looks like this:

$query = "SELECT antique_stores.StoreName, antique_stores.StoreAddress1, antique_stores.StoreCity, antique_stores.StoreZip, antique_stores.StoreTelephone
FROM antique_stores INNER JOIN Cities ON antique_stores.StoreCity = Cities.CityName
WHERE Cities.CityID = ".$city;

I want to do something similar but have more requirements:

$query = "SELECT * FROM SaleListing
INNER JOIN Cities
SaleListing.SaleCity = Cities.CityName
WHERE SaleCity = ".$SaleCity." AND Day1Date= '".$searchdate."' AND Cities.CityID = ".$SaleCity;

I've tested for both variables $SaleCity and $searchdate and they are being successfuly passed. $SaleCity is a number for the city from the Cities db.

This query is working great but I really need to substitute the CityName for the SaleCity/CityID number so that it shows the name instead:

$query = "SELECT * FROM SaleListing WHERE SaleCity = ".$SaleCity." AND Day1Date= '".$searchdate."'";

Any ideas? Thanks!
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.