Jump to content

Complicated Join Query.


iceblox

Recommended Posts

Hi Guys,

 

I know what im trying to do is possbile just not sure how! This is what i have already but its just to start

 

$query = "SELECT m2.ModelID FROM models m1 INNER JOIN deals m2 ON m1.modid=m2.ModelID
WHERE m1.modid='$modid'";

 

Basically i have a table called 'deals' with my mobile phone deals and my mobile phones are stored in 'models'. On this particular page the ModelID from the models table is in the URL as a variable. What id like to do is if the deals table has no deals in it based on the ModelID then dont show any deals if it does then show.

 

Any help would be appreciated

 

Phil

Link to comment
https://forums.phpfreaks.com/topic/77976-complicated-join-query/
Share on other sites

I don't quite get what you want to do.

 

Do you want to select data/information in the 'models' table based on the id of the row in the 'deals' table?

I would suggest having two separate queries for this, because currently, you have an inner join that is selecting a column from only one table, which to me, seems pointless.

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.