SELECT s.id,s.sell_number,s.sell_com_number,s.sell_com_name,s.sell_com_price,s.sell_quantity,s.sell_customer,s.sell_phone,s.sell_time,s.sell_staff FROM sys_user u,sys_org o,test_type t,test_commodity c,test_sell s WHERE u.org = o.id AND o.id=t.type_org AND u.username='admin' AND c.com_type = t.type_number AND c.com_number=s.sell_com_number
当 u.org为空时直接执行selcet * from test_sell
SELECT s.id,s.sell_number,s.sell_com_number,s.sell_com_name,s.sell_com_price,
s.sell_quantity,s.sell_customer,s.sell_phone,s.sell_time,s.sell_staff
FROM sys_user u,sys.org o,test_type t,test_commodity c,test_sell s
WHERE u.org<>'' and u.org = o.id AND o.id=t.type_org AND
u.username='admin' AND
c.com_type = t.type_number AND c.com_number=s.sell_com_number
union
SELECT s.id,s.sell_number,s.sell_com_number,s.sell_com_name,s.sell_com_price,
s.sell_quantity,s.sell_customer,s.sell_phone,s.sell_time,s.sell_staff
FROM test_sell s
s.sell_quantity,s.sell_customer,s.sell_phone,s.sell_time,s.sell_staff
FROM sys_user u,sys.org o,test_type t,test_commodity c,test_sell s
WHERE u.org<>'' and u.org = o.id AND o.id=t.type_org AND
u.username='admin' AND
c.com_type = t.type_number AND c.com_number=s.sell_com_number
union
SELECT s.id,s.sell_number,s.sell_com_number,s.sell_com_name,s.sell_com_price,
s.sell_quantity,s.sell_customer,s.sell_phone,s.sell_time,s.sell_staff
FROM test_sell s
温馨提示:答案为网友推荐,仅供参考