gpt4 book ai didi

mysql - 自定义列的多个值

转载 作者:行者123 更新时间:2023-11-29 02:30:16 25 4
gpt4 key购买 nike

我希望每个 ID 都有 2 个 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

SELECT ID, (ID*2) as CustomVal FROM tableNAme
UNION ALL
SELECT ID, (ID*4) as CustomVal FROM tableNAme
ORDER BY ID

关于mysql - 自定义列的多个值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14373438/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com