Hi!

Is it possible to use IF in the FROM part of a SELECT statement?

I've got three tables:

Profiles:
  ID: int
  CityID: int

Cities1:
  ID: int
  Name: VarChar 255

Cities2:
  ID: int
  Name: VarChar 255

Now I'd like to use Cities2 if the CityID in the table Profiles is
bigger than 70000.

Would this work?

SELECT Cities.Name FROM Profiles, 
  IF(Profiles.CityID > 70000, Cities1, Cities2) AS Cities
  WHERE Profiles.ID = Cities.ID
  AND Profiles.ID = 4711;

Thanks,

Alexander Skwar

filter: sql
-- 
How to quote:   http://learn.to/quote (german) http://quote.6x.to (english)
Homepage:       http://www.digitalprojects.com   |   http://www.iso-top.de
   iso-top.de - Die günstige Art an Linux Distributionen zu kommen
                Uptime: 5 hours 40 minutes

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to