我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

解决方案 »

  1.   

    select a.* from a inner join b on a.id=b.id
    order by b.type,b.id
      

  2.   

    select A.*
    from A,B
    where A.id=B.id
    order by B.type
      

  3.   

    select a.* from 
    a,b
    where a.id=b.id
    order by b.type;
      

  4.   

    select a.* from 
    a,b
    where a.id=b.id
    order by b.type; 
    这个可以
      

  5.   

    select *
    from A
    order by (select min(confirm) from B where id=A.id)
      

  6.   

    $sql = "SELECT a.pro_name,b.* FROM A a 
       INNER JOIN B b ON b.pro_id = a.id
       ORDER BY b.confirm ASC,b.type DESC";
    试试这个