Select in two mysql tables, Concat rows from 2nd table
Posted: 30 Oct 2016, 08:25
I use mysql Inner join with php for a select from two data tables.But the resuts are duplicated because in one table i have more results with that id.
this is my mysql select.but in upload_data i have three file name with that id.And i get tree results returned.How can i foreach this values?or any other thing?
Code: Select all
$sql2 = "SELECT `products`.`id` , `products`.`id_user` , `products`.`name` , `products`.`description` , `products`.`cantitate` , `products`.`data_expirare`,`products`.`data_cumparare`, `upload_data`.`FILE_NAME`,`upload_data`.`product_id`
FROM `products` , `upload_data`
where `products`.`id`=`upload_data`.`product_id` AND `products`.`id_user` = '$id' ";
$result2 = $conn->query($sql2);
if ($result2->num_rows > 0) {
while($row2 = $result2->fetch_assoc()) {