gpt4 book ai didi

mysql - 从 2 个表中选择

转载 作者:行者123 更新时间:2023-11-29 01:33:16 24 4
gpt4 key购买 nike

我的表:

表1

id|name_transfer|id_account_from|value_from|id_account_to|value_to
------------------------------------------------------------------
1 |transfer1 |1 |1000 |2 |1000

表2

id|name_account|
----------------
1 |account1 |
2 |account2 |

如何编写查询,我给出了这个:

transfer1|account1|1000|account2|1000

最佳答案

select
t1.name_transfer,
t2a.name_account as name_account_from,
t1.value_from,
t2b.name_account as name_account_to,
t1.value_to
from
table1 t1
inner join table2 t2a on t2a.id = t1.id_account_from
inner join table2 t2b on t2b.id = t1.id_account_to
where
t1.id = 1

关于mysql - 从 2 个表中选择,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4978614/

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