把我看看这个sql代码这样写有什么意义
SELECT OZ_BK_INLAND.*,OZ_BK_CUSTOMS_DECLARATION.BROKER_NAME,
OZ_BK_CUSTOMS_DECLARATION.BROKER_CONTACT,OZ_BK_CUSTOMS_DECLARATION.BROKER_TEL
FROM (select oz_bk_inland.JOB_ORDER_ID,trucker_name,OZ_BK_INLAND.bk_inland_id,trucker_contact,trucker_tel,Input_userName,
input_tel,input_fax,input_Email,OZ_BK_INLAND.input_date,cust_Deadline,T_B_G_RELATION_ID,OZ_BK_CARGO.cargo_DESCRIPTION,
'' AS TRUCKER_FREIGHT,cust_Address,cust_contact,cust_tel,cust_fax,trucker_instructions,CUTE_DATE,POL_NAME,POD_NAME
from OZ_BK_INLAND,OZ_BK_CARGO,OZ_BK_HEADER where oz_BK_INLAND.JOB_ORDER_ID=OZ_BK_CARGO.JOB_ORDER_ID
AND OZ_BK_INLAND.JOB_ORDER_ID=OZ_BK_HEADER.JOB_ORDER_ID and OZ_BK_INLAND.bk_inland_id='TA12040002')
AS OZ_BK_INLAND LEFT JOIN OZ_BK_CUSTOMS_DECLARATION ON OZ_BK_INLAND.T_B_G_RELATION_ID=OZ_BK_CUSTOMS_DECLARATION.T_B_G_RELATION_ID
这样编译的结果跟括号里面拿出来直接编译的结果一样 ··我不知道对方为什么要这样写··现在我要外连接个sb_user的表,添加sb_usr的TEl,fax,email,条件是sb_user.usr_code=oz_bk_inland.input_userName 要怎么才能办到
------解决方案--------------------
SELECT OZ_BK_INLAND.*,OZ_BK_CUSTOMS_DECLARATION.BROKER_NAME,
OZ_BK_CUSTOMS_DECLARATION.BROKER_CONTACT,OZ_BK_CUSTOMS_DECLARATION.BROKER_TEL
FROM (select oz_bk_inland.JOB_ORDER_ID,trucker_name,OZ_BK_INLAND.bk_inland_id,trucker_contact,trucker_tel,Input_userName,
input_tel,input_fax,input_Email,OZ_BK_INLAND.input_date,cust_Deadline,T_B_G_RELATION_ID,OZ_BK_CARGO.cargo_DESCRIPTION,
'' AS TRUCKER_FREIGHT,cust_Address,cust_contact,cust_tel,cust_fax,trucker_instructions,CUTE_DATE,POL_NAME,POD_NAME ,
sb_usr.TEl,sb_usr.fax,sb_usr.email
from OZ_BK_INLAND,OZ_BK_CARGO,OZ_BK_HEADER where oz_BK_INLAND.JOB_ORDER_ID=OZ_BK_CARGO.JOB_ORDER_ID
AND OZ_BK_INLAND.JOB_ORDER_ID=OZ_BK_HEADER.JOB_ORDER_ID and OZ_BK_INLAND.bk_inland_id='TA12040002')
AS OZ_BK_INLAND LEFT JOIN OZ_BK_CUSTOMS_DECLARATION ON OZ_BK_INLAND.T_B_G_RELATION_ID=OZ_BK_CUSTOMS_DECLARATION.T_B_G_RELATION_ID
LEFT JOIN sb_usr ON sb_user.usr_code=oz_bk_inland.input_userName
------解决方案--------------------
SQL code
SELECT
OZ_BK_INLAND.*,
OZ_BK_CUSTOMS_DECLARATION.BROKER_NAME,
OZ_BK_CUSTOMS_DECLARATION.BROKER_CONTACT,
OZ_BK_CUSTOMS_DECLARATION.BROKER_TEL
FROM
(
select
oz_bk_inland.JOB_ORDER_ID,
trucker_name,
OZ_BK_INLAND.bk_inland_id,
trucker_contact,
trucker_tel,
Input_userName,
input_tel,
input_fax,
input_Email,
OZ_BK_INLAND.input_date,
cust_Deadline,
T_B_G_RELATION_ID,
OZ_BK_CARGO.cargo_DESCRIPTION,
'' AS TRUCKER_FREIGHT,
cust_Address,
cust_contact,
cust_tel,
cust_fax,
trucker_instructions,
CUTE_DATE,
POL_NAME,
POD_NAME
from
OZ_BK_INLAND,
OZ_BK_CARGO,
OZ_BK_HEADER
where
oz_BK_INLAND.JOB_ORDER_ID=OZ_BK_CARGO.JOB_ORDER_ID
AND OZ_BK_INLAND.JOB_ORDER_ID=OZ_BK_HEADER.JOB_ORDER_ID
and OZ_BK_INLAND.bk_inland_id='TA12040002'
)AS OZ_BK_INLAND --这里面的子查询返回的数据作为一个新表,取名OZ_BK_INLAND
LEFT JOIN
OZ_BK_CUSTOMS_DECLARATION --用OZ_BK_INLAND和OZ_BK_CUSTOMS_DECLARATION左连接查询
ON
OZ_BK_INLAND.T_B_G_RELATION_ID=OZ_BK_CUSTOMS_DECLARATION.T_B_G_RELATION_ID