a.*,
e.bssamt FROM
(SELECT
bplic.*
FROM
BidPblancListInfoCnstwkInnoDB AS bplic
INNER JOIN
(SELECT DISTINCT
bidNtceNo,
bidNtceOrd
FROM
BidPblancListInfoLicenseLimitInnoDB
WHERE lcnsLmtCode IN (
'0001',
'0002',
'0010',
'0020',
'0036',
'0037',
'1458',
'1459',
'1460'
)
AND rgstDt BETWEEN '2017-10-01'
AND '2019-03-31') AS lncs
ON (
lncs.bidNtceNo = bplic.bidNtceNo
AND lncs.bidNtceOrd = bplic.bidNtceOrd
)
INNER JOIN
(SELECT DISTINCT
bidNtceNo,
bidNtceOrd
FROM
BidPblancListInfoPrtcptPsblRgnInnoDB
WHERE area_code_int IN (
110000,
111100,
111400,
111700,
112000,
112150,
112300,
112600,
112900,
113050,
113200,
113500,
113800,
114100,
114400,
114700,
115000,
115300,
115450,
115600,
115900,
116200,
116500,
116800,
117100,
117400,
280000,
281100,
281400,
281700,
281850,
282000,
282300,
282370,
282450,
282600
)
AND rgstDt BETWEEN '2017-10-01'
AND '2019-03-31') AS bplippr
ON (
bplippr.bidNtceNo = bplic.bidNtceNo
AND bplippr.bidNtceOrd = bplic.bidNtceOrd
)
INNER JOIN ordering_list AS ol
ON (
ol.ord_code = bplic.ntceInsttCd
AND ord_parent IN (
'1',
'2',
'3',
'4',
'5',
'6',
'7',
'8',
'9',
'10',
'11',
'12',
'13',
'14'
)
)
INNER JOIN BidPblancListInfoCnstwkBsisAmount AS bplicba
ON (
bplic.bidNtceNo = bplicba.bidNtceNo
AND bplic.bidNtceOrd = bplicba.bidNtceOrd
)
WHERE bplic.opengDt BETWEEN '2018-01-01 00:00:00'
AND '2018-12-31 23:59:59'
AND bplicba.bssamt >= 100000000
AND bplicba.bssamt <= 10000000000
AND (
bplic.bidMethdNm LIKE '전자입찰%'
OR bplic.dcmtgOprtnDt IS NOT NULL
OR bplic.reNtceYn = 'Y'
OR bplic.cmmnSpldmdMethdCd IN ('1', '2', '3', '6')
OR bplic.bidMethdNm LIKE '전자시담%'
OR bplic.cntrctCnclsMthdNm LIKE '수의%'
OR bplic.cntrctCnclsMthdNm LIKE '수의%여성%'
OR bplic.ntceKindNm IN (
'변경',
'취소',
'긴급',
'재입찰'
)
)
ORDER BY bplic.opengDt DESC
LIMIT 0, 15) AS a
LEFT JOIN BidPblancListInfoCnstwkBsisAmount AS e
ON (
a.bidNtceNo = e.bidNtceNo
AND a.bidNtceOrd = e.bidNtceOrd
)
데이터가 많은 테이블경우 조건을 먼저 실행하여 조건에 만족하는 적은 데이터를 조인하여 폼으로 이용