+ -
当前位置:首页 → 问答吧 → MySQL 求助

MySQL 求助

时间:2013-12-14

来源:互联网

小弟有个 MySQL 问题想请教各师兄, 我有两个 table, table1 同 table2, 想出返晒 table1 既 records, 但次序有 d 棘手, first order 系 table1.account, 即是601, 602, 跟住 second order 要 based on table2, 如果 table2 有 group 到, 就要将 telephone 放埋一齐出先, 即是出左 601 既 group1
22220000, 22220001, 22220003 先, 之后到 601 group2, 22220005, 22220007, 余下 601 冇o系 table2 做 grouping 既 22220002, 22220004,22220006.

请问一条 SQL 做唔做到呢? 唔该晒.



[ 本帖最后由 footballr 於 2013-10-28 04:13 PM 编辑 ]

作者: footballr   发布时间: 2013-12-14

select * from table1 t1
left join table2 t2 on t1.account = t2.account
order by t1.account, t2.group

作者: wing1234   发布时间: 2013-12-14