GamesNET2
asked on
MySQL Select distinct query problem
Hi there,
I have the code below - when I run it it does not give me a DISTINCT list of 'title', however if i take away col_id_6 then it works,
Any ideas?
I have the code below - when I run it it does not give me a DISTINCT list of 'title', however if i take away col_id_6 then it works,
Any ideas?
SELECT DISTINCT exp_channel_titles.title, exp_matrix_data.col_id_5
FROM exp_channel_titles
LEFT JOIN exp_channel_data ON exp_channel_titles.entry_id = exp_channel_data.entry_id
LEFT JOIN exp_relationships ON exp_channel_data.entry_id = exp_relationships.rel_child_id
LEFT JOIN exp_relationships AS exp_rel ON exp_rel.rel_child_id = exp_relationships.rel_parent_id
LEFT JOIN exp_matrix_data ON exp_rel.rel_parent_id = exp_matrix_data.entry_id
WHERE exp_channel_data.channel_id = 1 AND exp_matrix_data.col_id_5 IS NOT NULL
ORDER BY exp_matrix_data.col_id_5 ASC
LIMIT 0, 10
hi,
try adding
cus i think distinct a, b you give the cross distinct cvalues
try adding
group by exp_channel_titles.title
instead of distinctcus i think distinct a, b you give the cross distinct cvalues
ASKER
Ineed it was 5, the GROUP BY works for the grouping, but then the ORDER BY doesn't work properly...
?!
?!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Hi GamesNET2, how are you doing? Made some progress?
ASKER
Yes! Sorry I was so caught up in the success of it I forgot to come back, will award points tomorrow from a desk!
this article might give more insight about this kind of "problems":
https://www.experts-exchange.com/A_3203.html
https://www.experts-exchange.com/A_3203.html
What columns are in your output if you change to: select * from ...