我从多个表中选择了计数,但列是'虽然在这里使用As子句代码
,但名称不会改变SELECT * FROM
(SELECT COUNT(ID) FROM new_cards WHERE Bill_ID = '584762578412569') AS newcards,
(SELECT COUNT(ID) FROM sold_cards WHERE Bill_ID = '584762578412569') AS soldcards
我得到2列,他们的名字都是COUNT(ID)
答案 0 :(得分:1)
您的查询为子查询(表别名)而不是列分配别名。将别名移到列应修复它:
SELECT * FROM
(SELECT COUNT(ID) AS newcards FROM new_cards WHERE Bill_ID = '584762578412569') n,
(SELECT COUNT(ID) AS soldcards FROM sold_cards WHERE Bill_ID = '584762578412569') s