mds1256 Posted July 13, 2013 Share Posted July 13, 2013 Hi I am faced with the following problem. My table is as follows: part_idsupplier_idcustomer_id p1s1c1 p2s1c1 p3s2c1 p4s2c2 p5s1c2 And I need to return all customer ids where the customer has bought a part from the same supplier more than once. Any help would be appreciated Link to comment https://forums.phpfreaks.com/topic/280134-sql-query-help-please/ Share on other sites More sharing options...
mac_gyver Posted July 13, 2013 Share Posted July 13, 2013 SELECT customer_id FROM your_table GROUP BY customer_id,supplier_id HAVING count(*) > 1 Link to comment https://forums.phpfreaks.com/topic/280134-sql-query-help-please/#findComment-1440638 Share on other sites More sharing options...
mds1256 Posted July 13, 2013 Author Share Posted July 13, 2013 SELECT customer_id FROM your_table GROUP BY customer_id,supplier_id HAVING count(*) > 1 Thank you!!! That worked exactly, looks simple but have been trying to do this for around 4 hours Much appreciated. Link to comment https://forums.phpfreaks.com/topic/280134-sql-query-help-please/#findComment-1440639 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.