我是使用SQL的新用戶。 我做了一個查詢,我正在獲取重複的記錄。以下是我的查詢,然後是輸出。我想這個問題是我設置條件('WHERE ...')的地方。查詢輸出中的重複記錄
任何意見可以理解的輸出
SELECT
lmm.authorised_quota.fishery_type_code AS fishery,
lmm.authorised_quota.season_end AS season,
lmm.authorised_quota.authorised_licence_id AS licen_id_auth,
lmm.licences.licence_id AS licence_id_lic,
lmm.licences.certificate_number AS certificate_number,
lmm.certificates.certificate_number AS certificate_number,
lmm.certificates.client_id AS client_id,
lmm.clients.client_id AS client_id,
lmm.vessel_owners.client_id AS client_id,
lmm.vessel_owners.vessel_id AS vessel_id,
lmm.vessels.vessel_id AS vessel_id,
lmm.vessels.overall_length AS over_length,
lmm.vessels.beam_length AS beam_length,
lmm.vessels.gross_tonnage AS gross_tonnage,
lmm.vessels.port_code AS port_code,
lmm.ports.port_code AS port_code,
lmm.ports.port_name AS port_name,
lmm.ports.state AS state
FROM lmm.authorised_quota,
lmm.licences,
lmm.certificates,
lmm.clients,
lmm.vessel_owners,
lmm.vessels,
lmm.ports
WHERE lmm.authorised_quota.fishery_type_code = 'RLQ'
AND lmm.ports.state = 'TAS'
AND lmm.authorised_quota.seASon_end = '28/feb/99'
AND lmm.authorised_quota.authorised_licence_id = lmm.licences.licence_id
AND lmm.licences.certificate_number = lmm.certificates.certificate_number
AND lmm.certificates.client_id = lmm.clients.client_id
AND lmm.clients.client_id = lmm.vessel_owners.client_id
AND lmm.vessel_owners.vessel_id = lmm.vessels.vessel_id
AND lmm.vessels.port_code = lmm.ports.port_code
ORDER BY
lmm.clients.client_id,
lmm.vessel_owners.vessel_id;
部分:
CLIENT_ID CLIENT_ID_1 CLIENT_ID_2 VESSEL_ID VESSEL_ID_1 OVER_LENGTH BEAM_LENGTH GROSS_TONNAGE PORT_CODE
28 28 28 29 29 17.1 4.88 38.5 6120
28 28 28 29 29 17.1 4.88 38.5 6120
760 760 760 31 31 13.1 4.36 27.1 6080
760 760 760 31 31 13.1 4.36 27.1 6080
625 625 625 31 31 13.1 4.36 27.1 6080
625 625 625 31 31 13.1 4.36 27.1 6080
嗨約翰
DISTINCT
記錄,它的工作。非常感謝,拉斐爾 – Rafael不客氣! gald聽到:D –