gpt4 book ai didi

php - MySql 从一个 id 中获取两个值

转载 作者:行者123 更新时间:2023-11-29 00:33:36 26 4
gpt4 key购买 nike

我在下面有这个 sql 查询,注意字段 receivertable_1

返回 id

我的问题是如何在 receiver 点获取接收者 FirstNameLastName

SELECT DISTINCT
FirstName,
LastName,
table_2.status,
(select FirstName, LastName from table_1 where table_1.id = table_2.receiver) as receiver
FROM table_1
INNER JOIN
table_2 on table_1.key_2 = CONCAT('OFFLINE-', table_2.id)
ORDER BY FirstName, LastName

我在我的 SQL 中添加了一个子查询,但这给了我一个语法错误:(

最佳答案

select distinct FirstName, LastName, table_2.status, CONCAT(FirstName, ' ', LastName) 
from table_1 inner join table_2 on table_1.key_2 = CONCAT('OFFLINE-', table_2.id)
order by FirstName, LastName

关于php - MySql 从一个 id 中获取两个值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15393008/

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