我A表是产品表
id pro_name
1 a
2 b
3 cB表是产品订单列表
id pro_id type confirm
1 1 1 1
2 1 0 1
3 2 1 0我想select A的数据中
B表中未确定(0)的类型为1的产品排在前面...那么列出来的数据应该是
b a c..应该怎么写select
id pro_name
1 a
2 b
3 cB表是产品订单列表
id pro_id type confirm
1 1 1 1
2 1 0 1
3 2 1 0我想select A的数据中
B表中未确定(0)的类型为1的产品排在前面...那么列出来的数据应该是
b a c..应该怎么写select
order by b.type,b.id
from A,B
where A.id=B.id
order by B.type
a,b
where a.id=b.id
order by b.type;
a,b
where a.id=b.id
order by b.type;
这个可以
from A
order by (select min(confirm) from B where id=A.id)
INNER JOIN B b ON b.pro_id = a.id
ORDER BY b.confirm ASC,b.type DESC";
试试这个