mysql 多表多字段报表填充查询(MySQL multi table and multi field report filling query)

mysql 多表多字段报表填充查询

当需要2个数据从不同表时:

select *
from (  select count(id)as org_sum  FROM `jnx_drive` WHERE  user_id =1 and drive_type =1)as a1,
     ( select sum(money)as money,sum(score)as score FROM `sys_user`)as a2

继续添加字段:

,(SELECT count(id) FROM org WHERE user_id = "test_user_id"  and is_disable = 0  order by id DESC  )as a3
————————

MySQL multi table and multi field report filling query

When 2 data from different tables are required:

select *
from (  select count(id)as org_sum  FROM `jnx_drive` WHERE  user_id =1 and drive_type =1)as a1,
     ( select sum(money)as money,sum(score)as score FROM `sys_user`)as a2

Continue adding fields:

,(SELECT count(id) FROM org WHERE user_id = "test_user_id"  and is_disable = 0  order by id DESC  )as a3