How to connect these three mysql statements to selectco_balance, forward (*) afromdt_staffwherestaff_shouye, and how to connect these three mysql statements together
Select co_balance, co_isstaff from dt_co where co_id = 156
Select staff_group_id from dt_staff where co_id = 156
Select count (*) a from dt_staff where staff_shouyetuijian = 1 and co_id = 156
Online !!!
------ Solution --------------------
SELECT co_balance AS a, co_isstaff AS B, 1 AS TYPE FROM dt_co WHERE co_id = 156
UNION ALL
SELECT staff_group_id AS a, ''AS B, 2 AS TYPE FROM dt_staff WHERE co_id = 156
UNION ALL
Select count (*) AS a, ''AS B, 3 AS TYPE FROM dt_staff WHERE staff_shouyetuijian = 1 AND co_id = 156
Determine the query results of SQL statements a and B based on the type.
------ Solution --------------------
Select co_balance, co_isstaff, staff_group_id, count
From
(Select co_balance, co_isstaff from dt_co where co_id = 156),
(Select staff_group_id from dt_staff where co_id = 156) B,
(Select count (*) as count from dt_staff where staff_shouyetuijian = 1 and co_id = 156) c