Jump to content

[SOLVED] Table Join


iceblox

Recommended Posts

Hi Guys,

 

I have a table join which works fine. The tables are as below;

 

{Code Table}

modid / ModelID

1      /  52

1      / 53

 

{models table}

modid / modelname / Makename

1      / Nokia        /  5310

 

{Deals Table}

ModelID / MakeName/ ModelName

52        / Nokia      / 5310 Red

53        / Nokia      / 5310 Blue

 

This is my query which isnt working..

 

	$res = $db->sql_query("SELECT deals.MakeName, deals.ModelName, deals.ModelID, code.modelid FROM code INNER JOIN deals ON code.modelid = deals.ModelID WHERE deals.ModelID != code.modelid GROUP BY deals.ModelName ORDER BY deals.MakeName, deals.ModelName ASC");

 

 

What id like to do is only display ModelIDs which are not in the code table already.. if this makes sense? tried to sort it but not having any luck..

 

 

Cheers, Phil

 

 

Link to comment
https://forums.phpfreaks.com/topic/85805-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.