dadamssg87 Posted May 27, 2011 Share Posted May 27, 2011 I have a table thats filled like the following. I want to get all the names for each row associated with a certain 'cal_id' but i don't want duplicate names. So this query i want would return "Some", "Random", "names", "of", "groups". Is there any easy way to do this with sql? or am i better off getting all the names in an array and then using array_unique()? id | cal_id | name | 1 | 66 Some | 2 | 66 | Some | 3 | 14 | Random | 4 | 66 | Random | 5 | 66 | names | 6 | 66 | names | 7 | 66 | names | 8 | 66 | of | 9 | 66 | groups | 9 | 66 | groups | Quote Link to comment https://forums.phpfreaks.com/topic/237674-sql-array-unique/ Share on other sites More sharing options...
requinix Posted May 27, 2011 Share Posted May 27, 2011 Use DISTINCT. SELECT DISTINCT name FROM table WHERE cal_id = whatever Quote Link to comment https://forums.phpfreaks.com/topic/237674-sql-array-unique/#findComment-1221396 Share on other sites More sharing options...
dadamssg87 Posted May 27, 2011 Author Share Posted May 27, 2011 awesome, thanks Quote Link to comment https://forums.phpfreaks.com/topic/237674-sql-array-unique/#findComment-1221409 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.