i don't know how title problem properly.
heres table structure:
id | client_id | …
id
primary , auto increment. client_id
on other hand can occur multiple times.
what want fetch rows client_id
highest id
... heres example
id | client_id 1 | 1 2 | 1 3 | 2 4 | 3 5 | 2
so here client_id
1 , 2 occurs multiple times (because there newer version).
after query want following id
s in results: 2,4,5 (because highest id
in rows client_id
1 row id
2 , on)
if need columns can use select in
select * my_table (id, client_id) in ( select max(id), client_id my_table group client_id);
but if need id
select id my_table (id, client_id) in ( select max(id), client_id my_table group client_id);
or more simple
select max(id) my_table group client_id;
Comments
Post a Comment