Don't know your "where", but you probably want to something like ...

select USERS.name as name1, USERS.user_id as id1, USERS.name as name2,
USERS.user_id as id2 ...
where id1 = USERLIST.user_id and id2 = STUDENTLIST.user_id ...

4 tables join?

Mike Sosteric wrote:
> 
> >
> 
> Thanks Dibo but I don't think that will work. What I need as for
> 
> select USERS.name as name1, USERS.name as name2, USERLIST.user_id, 
>STUDENTLIST.user_id
> 
> and for name1 to refer to the user specified by USERLIST.user_id and
> and for name2 to refer to the user specified by STUDENTLIST.user_id
> 
> they will be two different names corrsponding to to totallyh different records. All 
>that query does is give me the name of the STUDENTLIST.user_id twice
> 
> mike
> 
> > > I' wondering if someone can help me out here.
> > >
> > > I need to do a three table join. Normally not a problem but in this case I have 
>to select usernames from a users table twice. One for each of two other tables. I'll 
>need to use a user_id (int) to do the select and then join on the name found. The 
>table structure looks something like this
> > >
> > > USERS
> > >  user_id
> > >  name
> > >
> > > USERLIST
> > >   user_id
> > >
> > > STUDENTLIST
> > >  user_id
> > >
> > > I want to be able to do something like this
> > >
> > > select USERS.name, USERS.name, USERLIST.user_id , STUDENTLIST.user_id student_id
> > > from USERS, USERLIST, STUDENTLIST
> >
> > select USERS.name as name1, USERS.name as name2, USERLIST.user_id, ...
> >
> > > WHERE
> > >
> > > and then have the name of the user from the user_id in both the USERLIST and the 
>STUDENTLIST
> > >
> > > my question is in a case like this, how do you correctly associate the 'name' 
>with each user_id??
> >
> > Done by where (via name1, name2 etc.)
> >
> > >
> > > tia for any help
> > >
> > > mike
> > >
> > > ---------------------------------------------------------------------
> > > 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
> 
> --
> Dr. Mike Sosteric <[EMAIL PROTECTED]>  Executive Director, ICAAP <www.icaap.org>
> Department of Global and Social Analysis Adjunct Professor, Masters of Publishing SFU
> Athabasca University, Athabasca Alberta,        cell 1 780 919 7569
> ------------------------------------------------------
> Spirit is the journey, Body is the bus I am the driver, from dust to dust
>                                                         -- Juluka --

---------------------------------------------------------------------
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