V
V
viktorross2020-05-13 23:22:00
MySQL
viktorross, 2020-05-13 23:22:00

Mysql left join query, how to fix?

hello, please tell me how can I add another left join to my code, I can’t figure out something, I’m a little confused,

I need to add one more condition, and take 2 rows from the class_ads_pictures table (folder and picture) where ad_id will be equal to the one what is displayed in this selection

, I added this line

left join  `class_ads_pictures` on  `class_messages`.ad_id =  `class_ads_pictures`.ad_id

but this led to the fact that the content from the table message is displayed 2 times, please guide
$messages_array=$db->fetchAssocList("select *, ".TABLE_MESSAGES.".id as `msg_id`, ".TABLE_MESSAGES.".pending as `pending`, date_format(".TABLE_MESSAGES.".`date`,'$date_format') as date_nice, ".TABLE_ADS.".$title_var as `title`, ".TABLE_ADS.".price as `price`, ".TABLE_MESSAGES.".ip as ip from ".TABLE_MESSAGES." left join  `class_ads_pictures` on  `class_messages`.ad_id =  `class_ads_pictures`.ad_id left join ".TABLE_ADS." on ".TABLE_ADS.".id = ".TABLE_MESSAGES.".ad_id left join ".TABLE_USERS." on ".TABLE_USERS.".id = ".TABLE_MESSAGES.".`from` $where"." order by ".TABLE_MESSAGES.".`".$order."` ".$order_way.$limit_str);

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question