SQLize Online / PHPize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
create table a (id int, name varchar(64)); insert into a values (1, 'a1'), (2, 'a2'); create table b (a_id int references a(id), d datetime, status int); insert into b values (1, '2022-01-01', 1), (1, '2022-01-02', 2), (1, '2022-01-03', 3), (2, '2022-01-01', 3), (2, '2022-01-02', 2); select a.* from a cross join (select * from b where b.a_id = a.id order by d desc limit 1) m
Stuck with a problem? Got Error? Ask ChatGPT!
Copy Clear