Tuesday, 12 June 2012

Multiple conditions in JOIN statement

You can put multiple conditions in your LEFT, RIGHT and INNER/OUTER joins if you want.. below a small example that will give you the idea.

SELECT tbl.id, tblo.naam
FROM sometable tbl
  LEFT JOIN someothertable tblo ON tblo.id = tbl.id
   AND tblo.function = tbl.function
ORDER BY ....

Didn't know this one.. could have saved me a lotta query's in the past :-(

No comments:

Post a Comment