我有两个表:第一个是父表,第二个是子表。我想从子表中选择所有父 id 的 2 条记录。
如何选择每个父母的唯一 2 条记录。
example :
parent table
parent_id group_name
1 first
2 second
child table
child_id parent_id name
1 1 'test1'
2 2 'test2'
3 1 'test3'
我已经尝试过 with 语句,但我发现所有父 ID 中只有一行