Re: [SQL ] 组资料问题

楼主: MOONY135 (谈无欲)   2019-10-24 10:58:13
※ 引述《cutekid (可爱小孩子)》之铭言:
: 网址: http://sqlfiddle.com/#!9/920483/18
: select *
: from orders t1
: inner join order_items t2 on t1.id = t2.order_id
: inner join commodities t3 on t2.match_id = t3.id
: inner join (
: select t1.id,min(manufacture_time) as m_time
: from orders t1
: inner join order_items t2 on t1.id = t2.order_id
: inner join commodities t3 on t2.match_id = t3.id
我后来的想法是这样
http://sqlfiddle.com/#!9/306fc6/4
把最小的manufacture_time JOIN 回order之后 就可以用两个字段来sort了
然后用orm查完之后再去组回传资料

Links booklink

Contact Us: admin [ a t ] ucptt.com