Jump to content

[SOLVED] Table join


iceblox

Recommended Posts

Hi all,

 

I have a table join that has been working but since i changed the where clause it no longer works.

 

This is the query

 

$query = "SELECT deals.MakeName, deals.ModelName, deals.ModelID, deals.ImageSmall, code.modelid
FROM deals
INNER JOIN code
ON deals.ModelID = code.modelid WHERE code.modid = $modid GROUP BY deals.ModelName";

 

Since changing

 

WHERE code.modid = $modid

to

WHERE code.modelid = $ModelID

 

it doesnt work!

 

I did some alterations which i thought would help me but in fact dont. I can get it to work like this

 

$query = "SELECT deals.MakeName, deals.ModelName, deals.ModelID, deals.ImageSmall, code.modelid
FROM deals
INNER JOIN code
ON deals.ModelID = code.modelid WHERE code.modid IN (SELECT modid FROM models WHERE affmodel = $ModelID) GROUP BY deals.ModelName";

 

But doesnt work how i want it too.

 

Any suggestions?

Link to comment
https://forums.phpfreaks.com/topic/104270-solved-table-join/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.