SELECT user_id, rep_nurse_1, rep_nurse_2
FROM Users
WHERE User_ID = 'x'

> I have a problem with a SELECT query. I have a users table and each user
> can
> be a Rep, Nurse or Administrator defined by User_Type. Each Rep has two
> Nurses allocated to them and the User_ID of the nurse is held in column
> Rep_Nurse_1 and Rep_Nurse_2. I am trying to perform a query that returns
> the
> two nurses details based on the User_ID of the Rep:
>
> SELECT U1.*, U2.*
> FROM Users U1, Users U2, Users R
> WHERE R.User_ID = 'x'
> AND U1.User_ID = R.Rep_Nurse_1
> AND U2.User_ID = R.Rep_Nurse_2
>
> However this returns just the first nurse allocated to that rep.
>
> I have listed my User table defination below and would be most grateful
> for
> anyones advice here.


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to