Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想每个 ID 有 2 个Custom_Column值。我怎样才能做到这一点?
Custom_Column
示例表:
ID 1 2 3
示例查询:
SELECT id, (id*2) as Custom_Value, (id*4) as Custom_Value FROM numbers
回复:
ID Custom_Value 1 2 1 4 2 4 2 8 3 6 3 12
采用UNION
UNION
SELECT ID, (ID*2) as CustomVal FROM tableNAme UNION ALL SELECT ID, (ID*4) as CustomVal FROM tableNAme ORDER BY ID