The fields that need to be queried are: customer number, customer name, customer cell phone, construction address, property name, area,
--Account Manager, Account Manager Mobile, designer, designer cell phone, main material designer, mobile,
--project manager, Project Manager cell phone, QC, QC phone
--Customer number, customer name, construction address, property name, area can be found directly from the table Sell_khxx
Select KHBH, KHXM,GCDZ,LPMC,JZMJ,KHJL,SJS,ZJSJS,XMJL from Sell_khxx
--Account manager, designer, master designer, project manager need to find the Code field in table Sell_khxx and Initialize_per
SELECT * FROM Initialize_per
SELECT * FROM Sell_khxx
--Find the name of the account manager, where a subquery is used to find the account manager's name
Select KHBH as customer number,
KHXM as Customer name,
(select Mingcheng from Initialize_per where CODE=A.KHJL) as account Manager
From Sell_khxx a where a.khbh= ' 2011070000001 '
--Find the name of the Account Manager, designer, main material designer, project manager
Select KHBH as customer number,
KHXM as Customer name,
(select Mingcheng from Initialize_per where CODE=A.KHJL) as Account Manager,
(select Mingcheng from Initialize_per where Code=a.sjs) as designer,
(select Mingcheng from Initialize_per where Code=a.zjsjs) as main material designer,
(select Mingcheng from Initialize_per where CODE=A.XMJL) as project manager
From Sell_khxx a where a.khbh= ' 2011070000001 '
--Customer cell phone, Account Manager cell phone, designer cell phone, main material designer cell phone, project manager cell phone, QC person mobile
Select KHBH as customer number,
KHXM as Customer name,
(select Shouji from Lianxifangshi where BIANMA=A.KHBH) as contact telephone,
(select Shouji from Lianxifangshi where BIANMA=A.KHJL) as Account Manager phone,
(select Shouji from Lianxifangshi where Bianma=a.zjsjs) as main material designer mobile phone,
(select Shouji from Lianxifangshi where BIANMA=A.XMJL) as project Manager mobile
From Sell_khxx a where a.khbh= ' 2011070000001 '
--Find the Account Manager, designer, main material designer, Project manager name, customer cell phone, Account Manager cell phone, designer cell phone, main material designer cell phone, project manager mobile
Select KHBH as customer number,
KHXM as Customer name,
(select Shouji from Lianxifangshi where BIANMA=A.KHBH) as contact telephone,
Gcdz as construction address,
LPMC as property name,
JZMJ as Area,
(select Mingcheng from Initialize_per where CODE=A.KHJL) as Account Manager,
(select Shouji from Lianxifangshi where BIANMA=A.KHJL) as Account Manager phone,
(select Mingcheng from Initialize_per where Code=a.sjs) as designer,
(select Shouji from Lianxifangshi where Bianma=a.sjs) as designer phones,
(select Mingcheng from Initialize_per where Code=a.zjsjs) as main material designer,
(select Shouji from Lianxifangshi where Bianma=a.zjsjs) as main material designer mobile phone,
(select Mingcheng from Initialize_per where CODE=A.XMJL) as project manager,
(select Shouji from Lianxifangshi where BIANMA=A.XMJL) as project Manager mobile
From Sell_khxx a where a.khbh= ' 2011070000001 '
--the inspection needs to be found through the KHBH field of table Sell_khxx and Paigongdan
--Find the number of the QC according to the Xiangmujingli field in the dispatch ticket
Select Xiangmujingli from Paigongdan where khbh= ' 2011070000001 '
--Find the name of the QC according to the Xiangmujingli field in the dispatch ticket
Select Mingcheng from Initialize_per where code= (select Xiangmujingli from Paigongdan where khbh= ' 2011070000001 ')
Select KHBH as customer number,
KHXM as Customer name,
(select Shouji from Lianxifangshi where BIANMA=A.KHBH) as contact telephone,
Gcdz as construction address,
LPMC as property name,
JZMJ as Area,
(select Mingcheng from Initialize_per where CODE=A.KHJL) as Account Manager,
(select Shouji from Lianxifangshi where BIANMA=A.KHJL) as Account Manager phone,
(select Mingcheng from Initialize_per where Code=a.sjs) as designer,
(select Shouji from Lianxifangshi where Bianma=a.sjs) as designer phones,
(select Mingcheng from Initialize_per where Code=a.zjsjs) as main material designer,
(select Shouji from Lianxifangshi where Bianma=a.zjsjs) as main material designer mobile phone,
(select Mingcheng from Initialize_per where CODE=A.XMJL) as project manager,
(select Shouji from Lianxifangshi where BIANMA=A.XMJL) as project manager phone,
(select Mingcheng from Initialize_per where code= (select Xiangmujingli from Paigongdan where KHBH=A.KHBH)) as quality inspection,
(select Shouji from Lianxifangshi where bianma= (select Xiangmujingli from Paigongdan where KHBH=A.KHBH)) as quality phone
From Sell_khxx a where a.khbh= ' 2011070000003 '
--fields that can be detected in table Sell_khxx
SELECT * from sell_khxx where khbh= ' 2011070000003 '
--Table Lianxifangshi identify the customer's phone
Select Bianma,shouji from Lianxifangshi where bianma= ' 2011070000003 '
--Check the phone number of the account manager
Select Bianma,shouji from Lianxifangshi where bianma= ' PR0011 '
Compound SQL statements for system data