gpt4 book ai didi

mysql - mysql根据多个id选择字段

转载 作者:行者123 更新时间:2023-11-29 19:44:37 26 4
gpt4 key购买 nike

有两个表表1

id --------- 姓名

10001ABC

10002 XYZ

表2

fromid ------ toid ------ 消息

10001 10002嗨

我希望结果是这样的

名称-----名称1------消息

Abc Xyz Hi

帮助将不胜感激

最佳答案

select t1.name as name, t2.name as name1, t3.message
from table2 as t3
join table1 as t2 on t3.fromid = t2.id
join table1 as t1 on t3.toid = t1.id

我想这可以满足你的问题。

关于mysql - mysql根据多个id选择字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41116042/

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