Advertisement

11.28.2008 at 01:24PM PST, ID: 23942979 | Points: 500
[x]
Attachment Details

How to SELECT DISTINCT and have random result GROUPing by

Tags:

SELECT DISTINCT, random

I have a RECORDSET wich gives me as result a list of tag names with a its link text.

I want to have this results with random order BUT I want to exclude from results WHERE link_tag value is redundant, I want unique value on link_tag column.

This recordset works BUT the link_tag value I get is always the same. Maybe because the ORDER BY is after the group by and not viceversa.

How can I do this and get 10 ramdom results from my tag list where link_tag column has unique value

1:
2:
3:
4:
SELECT DISTINCT tags_cat.*, tags_tag.*, rand() as randome
FROM (tags_tag LEFT JOIN tags_cat ON tags_cat.id_tags_cat=tags_tag.idcat_tag)
GROUP BY link_tag
ORDER BY randome desc LIMIT 10
 
 
 
Expert Comment by angelIII:

All comments and solutions are available to Premium Service Members only. Start your 7-day free trial to view the solution to this question.

Already a member? Login to view this solution.

 
 
Author Comment by Fernanditos:

All comments and solutions are available to Premium Service Members only. Start your 7-day free trial to view the solution to this question.

Already a member? Login to view this solution.

 
 
Expert Comment by angelIII:

All comments and solutions are available to Premium Service Members only. Start your 7-day free trial to view the solution to this question.

Already a member? Login to view this solution.

 
 
Author Comment by Fernanditos:

All comments and solutions are available to Premium Service Members only. Start your 7-day free trial to view the solution to this question.

Already a member? Login to view this solution.

 
 
Expert Comment by angelIII:

All comments and solutions are available to Premium Service Members only. Start your 7-day free trial to view the solution to this question.

Already a member? Login to view this solution.

 
 
Author Comment by Fernanditos:

All comments and solutions are available to Premium Service Members only. Start your 7-day free trial to view the solution to this question.

Already a member? Login to view this solution.

 
 
Expert Comment by angelIII:

All comments and solutions are available to Premium Service Members only. Start your 7-day free trial to view the solution to this question.

Already a member? Login to view this solution.

 
 
Author Comment by Fernanditos:

All comments and solutions are available to Premium Service Members only. Start your 7-day free trial to view the solution to this question.

Already a member? Login to view this solution.

 
 
20081119-EE-VQP-46 - Hierarchy / EE_QW_3_20080625