我需要检索这个结果:
ROW1.id | ROW2.id | ROW3.id | ROW4.id
1 | 2 | 3 | 4
从这个结果开始 select * from Table
:
id | value
1 | sample1
2 | sample2
3 | sample3
4 | sample4
有什么想法吗?
谢谢, 安德里亚
最佳答案
你可以这样做:
select
(select id from table X where X.something = 123) as row1Id,
(select id from table X where X.something = 456) as row2Id,
(select id from table X where X.something = 789) as row3Id
关于sql - 在单个记录上返回多行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3601134/