CanMan2004 Posted February 17, 2007 Share Posted February 17, 2007 Hi all I have a table which looks like id dmid pgid 43 14 56 10 9 6 26 7 21 42 22 6 I want to write a query which returns all rows, but groups them. For example, with the above data, it would return 3 rows, because there is 2 rows which have the same pgid, so that is classed as 1 row. So the query should return pgid: 6 pgid: 21 pgid: 56 but then I want to print under each row, the dmid value for each row in the database, for example pgid: 6 dmid: 9 dmid: 22 pgid: 21 dmid: 7 pgid: 56 dmid: 14 Does that make sense? Can anyone help? Thanks in advance Ed Link to comment https://forums.phpfreaks.com/topic/38843-unique-query/ Share on other sites More sharing options...
printf Posted February 17, 2007 Share Posted February 17, 2007 You have two different questions, because you can't use GROUP BY and expect the dmid values to be given to you. GROUP BY gives you unique record, so any matching records will not be included. You can do what you want via scripting! If thats ok, tell me I'll give you an example. printf Link to comment https://forums.phpfreaks.com/topic/38843-unique-query/#findComment-186767 Share on other sites More sharing options...
CanMan2004 Posted February 17, 2007 Author Share Posted February 17, 2007 Thanks, ive found a way to do it Link to comment https://forums.phpfreaks.com/topic/38843-unique-query/#findComment-186771 Share on other sites More sharing options...
printf Posted February 17, 2007 Share Posted February 17, 2007 If you found a way, it good idea that you post it, so maybe someone looking for the same kind of thing can see how you did it. printf Link to comment https://forums.phpfreaks.com/topic/38843-unique-query/#findComment-186772 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.