Click here to Skip to main content
15,887,776 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
I am using MySQL 2005.

So this is my problem.
I have this table:
SQL
Counter     Name     EmployeeNo
   1        Marc      2014001
   2        Mika      2014002
   3        Holly     2014003
   4        Cara      2014004


and this other table:
SQL
ID     Customer     EmployeeNo     Status
001      1B001        2014001        y
002      1G003        2014001        x
003      1G004        2014002        y
004      1B006        2014003        x


How can I show a table where i join them together like this:
SQL
Name    Customer
Marc     1G003
Mika     NULL
Holly    1B006
Cara     NULL


like checking the customers they've been assigned with. But only shows the customer with the status 'x' ??

Super Help! And super thanks in advance!
Posted
Updated 17-Jun-14 19:05pm
v2
Comments
PIEBALDconsult 18-Jun-14 0:16am    
Soooo.... where's your query?
charliedev 18-Jun-14 1:05am    
I'm sorry what query?

1 solution

Use a SQL Join clause. The Left outer join returns all rows in t1 even if no corresponding row in t2

select t1.name, t2.customer
t1 left outer join t2 on t1.EmployeeNo = t2.EmployeeNo and t2.status = 'x'
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900