I’m trying to do a SELECT from two tables in the same db. This is what I’m trying…
SELECT * FROM Orders O
JOIN Employees_Packers EP
O.PackedBy AS EP.UserName
WHERE O.Shipped = 0 ORDER BY Order_ID
I’m trying to get this SELECT to give me all the rows where Shipped = 0 and have the EP.UserName value to show instead of the O.PackedBy. What am I missing?
EP.UserName = a Name Value
O.PackedBy = an Number
If O.PackedBy was also a string, this would work:
But I’m guessing that O.PackedBy is a Foreign Key to EP.ID (whatever the unique id field is named). Try substituting EP.UserName with EP.ID.
EDIT:
OK – given the comment below:
This should join your two tables.
SELECT *will give you all of the fields in both tables. If you only want EP.UserName in the result, replace the * with EP.Username.