A
A
Artem Volkov2018-01-28 18:16:50
MySQL
Artem Volkov, 2018-01-28 18:16:50

How to form SQL query correctly?

Hello. Simple problem.
There is a table user_com in the database with the following fields
id, id_user, comment
1 #123 comment...
2 #123 comment...
3 #654 comment...
4 #334 comment...
5 #123 comment...
6 # 334 comment...
7 #123 comment...
I need to display id_user in a loop without repeating users
It should turn
out 1 id_user #123
2 id_user #654
3 id_user #334
So that they do not repeat

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
res2001, 2018-01-28
@AronTito

select id_user from user_com group by id_user

L
Lone Ice, 2018-01-28
@daemonhk

SELECT * FROM `user_com` GROUP BY `id_user`

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question