The used SELECT statements have a different number of columns

后端 未结 5 1678
执笔经年
执笔经年 2021-01-11 13:28

For examples I don\'t know how many rows in each table are and I try to do like this:

SELECT * FROM members 
UNION 
SELECT * FROM inventory

5条回答
  •  爱一瞬间的悲伤
    2021-01-11 13:41

    I don't know how many rows in each table

    Are you sure this isn't what you want?

    SELECT 'members' AS TableName, Count(*) AS Cnt FROM members 
    UNION ALL
    SELECT 'inventory', Count(*) FROM inventory
    

提交回复
热议问题