MySQL join problem
Posted
by David
on Stack Overflow
See other posts from Stack Overflow
or by David
Published on 2010-05-25T18:59:44Z
Indexed on
2010/05/25
19:11 UTC
Read the original article
Hit count: 275
Table1 has u_name, Table2 has u_name, u_type and u_admin
Table1.u_name is unique. But neither of the 3 fields in Table2 is unique.
For any value of Table1.u_name, there are 0 to many entries in Table2 that Table2.u_name equals to that value.
For any value of Table1.u_name, there are 0 to 1 entries in Table2 that Table2.u_name equals to that value AND Table2.u_type='S'
What I want: Use Table1.u_name to get Table1.*, Table2.u_admin where Table1.u_name=Tabl2.u_name and Table2.u_type='S'. If there is no such entry in Table2 we still need to get Table1.*
Please help give me some hints. Thank you so much!
© Stack Overflow or respective owner