johnwayne77 Posted September 21, 2008 Share Posted September 21, 2008 hello! i'm implementing an e-commerce system to distribute key codes. right now i'm thinking of a sql syntax to do the following: i have a table: orders here i have the orders_id field (unique for each order placed) with this orders_id field there may be more than one products ordered therefore in the products_id field i can have the following situation: orders_id: 101 products_id: 13 orders_id: 101 products_id: 43 orders_id: 101 products_id: 1 so i have three rows with the same orders_id but different products_id now i want to grab the value of these products_id for the specified orders_id (p.s. i can provide the orders_id value already) any ideas? i'm a little stuck on this.. thanks Quote Link to comment https://forums.phpfreaks.com/topic/125202-select-three-diferent-fields-related-to-a-common-field/ Share on other sites More sharing options...
F1Fan Posted September 22, 2008 Share Posted September 22, 2008 Not sure exactly what you're asking, but have you tried this: SELECT DISTINCT(products_id) FROM orders WHERE orders_id = $orders_id Quote Link to comment https://forums.phpfreaks.com/topic/125202-select-three-diferent-fields-related-to-a-common-field/#findComment-647443 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.