如何在我的SQL中连接两个查询

时间:2016-11-03 12:31:06

标签: mysql sql

 select concat_ws((
select count(*) from feed_back where schedule_id=1),'/',(select count(*) from event_schedule_mapping where event_schedule_id=1))
as total

我从两个查询中得到了数据,但是当我尝试使用concat concat_ws时,它给我blobdata为空白请告诉我哪里出错了请建议。

3 个答案:

答案 0 :(得分:0)

为什么concat_ws()而不是concat()

SELECT CONCAT( (First Select),
                '/'
               (Second Select)) as total

答案 1 :(得分:0)

首先使用分隔符尝试此操作:

    SELECT CONCAT_WS('/', 
        (select count(*) from feed_back where schedule_id=1), 
        (select count(*) from event_schedule_mapping where event_schedule_id=1))

String Functions - MySQL CONCAT_WS

答案 2 :(得分:0)

尝试这样



SELECT sum(a+b) as total FROM (SELECT count(*) as a from feed_back where schedule_id=1) as x, (SELECT count(*) as b FROM event_schedule_mapping where event_schedule_id=1) as y