List:General Discussion« Previous MessageNext Message »
From:Martin Edelius Date:November 2 1999 11:08am
Subject:using multiple tables in a 'where' statement?
View as plain text  
Hi.

I'm having troubles getting my select queries doing what I wan't, and I'm pretty sure that
this is because of me lacking some SQL skills...

I have a number of tables in the same database, looking something like this:
tableA(id varchar(30), firstname varchar(30), phone varchar(30))
tableB(id varchar(30), lastname varchar(30), fax varchar(30))

I want to do a query like this:
"select lastname from tableB where tableB.id=tableA.id and tableA.phone='123456'" 
but this won't work ("ERROR 1109: Unknown table 'tableA' in where clause"). 

After rummaging through the manual I managed to use tableA in the 'where' statement but
only if I also selected something from it but it resulted in a join and this is not what
I want to do (unless there is an intelligent way to do it and only get 'lastname' from
tableB sent back in the result set).

Is there a way around this? As mentioned I'm not that skilled in SQL besides the normal
"select...where" stuff. Is 'having' a better way to go? (Heh, if any of you guys feel
like pimping your books about MySQL/SQL, now's a good time to do it... 8)

Any help is appreciated.


Best regards,
Martin Edelius

Spirex Digital Design

--------------------------------
www: http://www.spirex.se
Mail: martin.edelius@stripped
Phone: +46-31-514651, 0708-113711
Fax: +46-31-514331
Aröds Industriväg 3c
S-422 43 Hisings Backa
--------------------------------
If I haven't gotten back to you or done what I'm supposed to, let me know again as I have
too much to do for my own good...



Thread
using multiple tables in a 'where' statement?Martin Edelius2 Nov
  • Re: using multiple tables in a 'where' statement?Bob Kline2 Nov