mysql veritabanı php için benzersiz bir alan

0 Cevap php

Ben, böyle bir örnek veritabanı sahip olduğu, kimliği her zaman tektir, ama User_id benzersiz değil.

id,user_id,message,msg_datetime
111,u1, msg from u1,time present here
112,u2, msg from u2,time present here
113,u3, msg from u3,time present here
114,u2, msg from u2,time present here
115,u7, msg from u7,time present here
116,u2, msg from u2,time present here
117,u1, msg from u1,time present here
118,u5, msg from u5,time present here

öylesine i msg_datetime tarafından DESC onları mesajla ve sipariş yalnızca bu eşsiz kullanıcıları kapmak istiyorum.

This is the query i have.
select id,DISTINCT user_id,msg_datetime ORDER BY msg_datetime DESC but i am getting an error as:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DISTINCT. any help here? what is the correct syntax for what i am trying to achieve?

Ben bu i gösteren ancak kullanıcı başına sadece 1 am hangi kimliği önemli değil, her kullanıcı için tek giriş göstermek istiyorum.

0 Cevap