gpt4 book ai didi

mysql - 使用不同行中的值对同一个表进行查询

转载 作者:行者123 更新时间:2023-11-29 18:20:15 25 4
gpt4 key购买 nike

我必须在 SQL 示例中的表的 2 行中显示同一行结果:

**Name     Lastname  address        U_Name**
John Smith 123 N Av NULL
E-mail NULL js@123.com John

Result
**Name Last name e-mail**
John Smith js@123.com

谢谢

我当前的查询如下所示

select C2.UREPEMAIL, 'NULL' as Source, CS.TITLE, CS.CONTACT, C1.COMPANY, C2.UGMNAME as Vendor, CS1.Contsupref, 'NULL', 
CS.PHONE, CS.EXT, CS.FAX, 'NULL', 'NULL', 'NULL' Skype, 'NULL', CS.TITLE, 'NULL', 'Department', 'NULL', 'NULL', 'Pref of Con',
'NULL', CS.ADDRESS1 + ' ' + CS. ADDRESS2, CS.CITY, CS. STATE, CS.ZIP, CS.COUNTRY, CS.ADDRESS3, 'NULL', 'NULL', 'NULL', 'NULL',
'NULL'
from CONTSUPP CS
INNER JOIN CONTSUPP CS1
ON CS.CONTACT = CS1.ADDRESS2
INNER JOIN CONTACT1 C1
ON C1.ACCOUNTNO = CS.ACCOUNTNO
INNER JOIN CONTACT2 C2
ON C2.ACCOUNTNO = CS.ACCOUNTNO

最佳答案

这个?

SELECT  a.Name,
a.Lastname,
b.Address
FROM YourTable a
JOIN YourTable b
ON a.Name = b.U_Name

关于mysql - 使用不同行中的值对同一个表进行查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46651536/

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