frank5050 Posted February 28, 2011 Share Posted February 28, 2011 Hello guys, I have 2 tables in my mySQL database. One table stores the customer info and the other table stores the products they ordered. "Order_ID" is the common variable in both tables. I have written a join query which pulls data from both tables. My query looks like this: $query = "SELECT c.*, p.Product_SKU from csm c, csmproducts p where c.Order_ID = p.Order_ID and c.Order_Status='Awaiting Fulfillment' group by Order_ID order by Order_ID DESC LIMIT $startrow, 50"; $numresults=mysql_query($query); $numrows=mysql_num_rows($numresults); } The trouble I am having is that I can query the database for a particular Order_ID, but if that Order_ID has multiple products in it , only the first product is showing. What do I need to do such that where {$row['Product_SKU']} gives me only the first product, I can pull all the Product_SKUs for that particular Order_ID. Currently the output looks like this (showing just the first item the customer orderd) Order ID: Product SKU 5558 DSC-3433 I would like to see it like this: Order ID: Product SKU 5558 DSC-3433 ASD-6454 UFY-7383 5559 ...................... on and on and on for next orders Thanks in advance for the assistance. Quote Link to comment https://forums.phpfreaks.com/topic/229093-simple-php-mysql-query/ Share on other sites More sharing options...
fenway Posted March 1, 2011 Share Posted March 1, 2011 You can't use group by and expect to get multiple rows! Quote Link to comment https://forums.phpfreaks.com/topic/229093-simple-php-mysql-query/#findComment-1181055 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.