SQL选择同一行数次,但具有不同的查询
我的SQL项目中有4个表格,我想在目前使用 2 不同的查询的1行。我设法获得了我想要的结果,但是我不知道如何在同一行中使用同一列获得另一个结果。
这是我现在的查询:
SELECT currencies.currency, swaps.you_send, swaps.you_send, currencies.currency
FROM currencies, swaps
WHERE swaps.currency_to = currencies.id
,然后我得到 this 结果
正如您在最后一行中看到的那样,有同一行,应该是不同的结果 对于不同的结果,需要此查询才能获得正确的结果
SELECT currencies.currency, swaps.you_send, swaps.you_get, currencies.currency
FROM currencies, swaps
WHERE swaps.currency_to = currencies.id
,然后我得到 this 结果,
但我需要的是,这是第一行货币中的第一个是
我与Union尝试的最后一排,但随后它们在彼此之间进行了显示。
如果有人可以帮助我解决这个问题,那会很友善。
I have 4 tables in my SQL project and I want to use the same row of 1 table with 2 different queries at the moment. I managed to get the result I wanted once but I can't figure out how to get another result with the same column in the same row.
This is my query now:
SELECT currencies.currency, swaps.you_send, swaps.you_send, currencies.currency
FROM currencies, swaps
WHERE swaps.currency_to = currencies.id
Then I get this as result
as you can see in the last row, there is the same row, that should be a different result
for the different result this query is needed to get the right result
SELECT currencies.currency, swaps.you_send, swaps.you_get, currencies.currency
FROM currencies, swaps
WHERE swaps.currency_to = currencies.id
Then I get this as result
But what I need is that results the first one in the first row of currency the second in the last one
I tried it with UNION but then they get shown among themselves.
Would be very kind if somebody could help me with this problem.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您选择了两次,这就是为什么您获得相同值的原因。
这样的事情应该可以工作:
我已经缩小了示例,因为我不知道您的SQL表。
请更新您的问题,以使其更清楚
You select twice the same, thats why you get the same value.
Something like this should work:
I have minifed the example because i dont know your SQL Tables.
Please update your question to make it more clear
谢谢,我设法以您的片段的灵感来完成。
Thanks I managed to do it with the inspiration of your snippet.