[thelist] Tricky SQL

Jay Blanchard jay.blanchard at niicommunications.com
Tue Jun 18 14:45:01 CDT 2002


[snip]
> "SELECT score FROM * WHERE gameDate = yesterday" to get
> all scores for all games played by all teams in all sports for yesterday.

presumably you want to search all tables, so use a union

  SELECT 'mens', score FROM soccer_mens
     WHERE gameDate = yesterday" to get
 UNION ALL
  SELECT 'womens', score FROM soccer_womens
     WHERE gameDate = yesterday" to get
 UNION ALL
   et cetera

the literal in the result set tells you which table the row came from
[/snip]

You can tell by my LEFT OUTER JOIN 'solution' that i am thinking in MySQL
mode....no UNION available....yet :)
AACK!

Jay





More information about the thelist mailing list