elpaisa Posted January 25, 2008 Share Posted January 25, 2008 Hi all! I don't know how to formulate this topic cos I have a mess in the quite big head. I need to take "imageid" and "title" fields from one table called images and take another "imageid" related of a second table, then to compare what imageids from the first table are not in the second table to show the records of the first one without showing the records whose imageid is in second table. All comments and help are welcome! Regards. Quote Link to comment https://forums.phpfreaks.com/topic/87786-solved-stuck-need-help-to-formulate-this-topic/ Share on other sites More sharing options...
GingerRobot Posted January 25, 2008 Share Posted January 25, 2008 If memory serves, then the query should be: SELECT table1.imageid, table1.title FROM table1 LEFT JOIN table2 USING imageid WHERE table2.imageid IS NOT NULL Quote Link to comment https://forums.phpfreaks.com/topic/87786-solved-stuck-need-help-to-formulate-this-topic/#findComment-449042 Share on other sites More sharing options...
revraz Posted January 25, 2008 Share Posted January 25, 2008 May have to use LEFT JOIN for that. Quote Link to comment https://forums.phpfreaks.com/topic/87786-solved-stuck-need-help-to-formulate-this-topic/#findComment-449043 Share on other sites More sharing options...
elpaisa Posted January 25, 2008 Author Share Posted January 25, 2008 Yes i used left join but shows the records existent in both tables for imageids related, what i need to do is show only records from table1 whose ids are not in table2 Quote Link to comment https://forums.phpfreaks.com/topic/87786-solved-stuck-need-help-to-formulate-this-topic/#findComment-449048 Share on other sites More sharing options...
elpaisa Posted January 25, 2008 Author Share Posted January 25, 2008 I think is just a simple left join query, but. Do i need some extra code to echo records only from table one? Quote Link to comment https://forums.phpfreaks.com/topic/87786-solved-stuck-need-help-to-formulate-this-topic/#findComment-449055 Share on other sites More sharing options...
elpaisa Posted January 25, 2008 Author Share Posted January 25, 2008 Solved! SELECT sd_p17_images.imageid, sd_p17_images.title FROM sd_p17_images LEFT JOIN sd_p17_meds ON sd_p17_images.imageid = sd_p17_meds.imageid WHERE sd_p17_meds.imageid IS NULL; Quote Link to comment https://forums.phpfreaks.com/topic/87786-solved-stuck-need-help-to-formulate-this-topic/#findComment-449083 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.