Reputation:
Currently I'm stuck with something that I think is easy to do but I'm going to ask it anyway.
I have a table called zg_data
which looks like this:
+---------------------+------------------+
| dataID | employee |
+---------------------+------------------+
| 12 | 123 |
+---------------------+------------------+
And a table called zg_employees
which looks like this:
+---------------------+------------------+------------------+
| employeeID | Firstname | Lastname |
+---------------------+------------------+------------------+
| 123 | Test | User |
+---------------------+------------------+------------------+
Now what I need to do is when selecting data from the zg_data
table instead of it returning the employeeID
I would like that it returns the Firstname
& Lastname
instead. I've been reading about joining tables but I haven't been able to figure it out just yet.
Upvotes: 0
Views: 204
Reputation: 37430
Well, it's basic JOIN
operation, you should be able to figure it out on your own if you are familiar with it:
select d.dataID, e.Firstname, e.Lastname
from zg_data d join zg_employee e on d.employee = e.employeeID
Upvotes: 2