목요일, 3월 12, 2009

아주 오랫만에 sql 을 써보는듯 하다.
주로 사용했떤 oracle, db2가 아니라 mysql 이어서인지 join문이 왜 이리 낫선지......

SELECT
LAAMLogMapping.LAAMLogID, b.companyID, c.companyName, b.customerName, LAAMLogMapping.serverName,
errLaamLog.procStatus, date_format(errLaamLog.occuDate, "%Y-%m-%d %H:%i") as occuDate, errLaamLog.seid,
(SELECT CONCAT(sename," ", sehphone) FROM semaster WHERE semaster.seid = errLaamLog.SEID) seinfo
FROM
LAAMLogMapping LEFT JOIN errLaamLog ON (LAAMLogMapping.LAAMLogID = errLaamLog.LAAMLogID AND errLaamLog.ProcStatus != '9'),
CustomerMaster b,
CompanyInfo c
WHERE
LAAMLogMapping.CustomerID = b.CustomerID
AND b.CompanyID = c.CompanyID
ORDER BY c.CompanyName, b.customerName

댓글 없음:

댓글 쓰기