sql >> Database teknologi >  >> RDS >> Oracle

forbinder flere borde

Okay, jeg kunne ikke teste denne pengeautomat, men jeg ville gøre noget som dette:

SELECT
    proj_id,
    project_estimates.Q1,
    project_estimates.Q2,
    project_estimates.Q3,
    project_estimates.Q4,
    project_expenditure.Q1,
    project_expenditure.Q2,
    project_expenditure.Q3,
    project_expenditure.Q4
FROM projects
LEFT JOIN project_estimates ON (project_estimates.proj_id = projects.proj_id)
LEFT JOIN project_expenditure ON (project_expenditure.proj_id = projects.proj_id)
WHERE projects.proj_id IN (
    (SELECT proj_id FROM project_estimates WHERE (project_estimates.fy = '2015-16'))
    UNION
    (SELECT proj_id FROM project_expenditure WHERE (project_expenditure.fy = '2015-16'))
GROUP BY proj_id
)
ORDER BY proj_id


  1. Ydeevne af forespørgsel på indekseret boolesk kolonne vs Datetime kolonne

  2. MySQL IN med LIKE

  3. Sådan indsætter du en hebraisk værdi i en mysql db i php

  4. billedtypen er ikke indstillet til polymorfe associationer