I'm sure this has been ask/answered already but I don't know how this kind of action is called and my SQL knowledge is limited.
I'm searching for a single SQL statement to merge two tables:
Table USER:
ID hash
=========
1 abc
2 def
3 ghi
and the USER_FIELD table:
ID user_id key value
=============================
1 1 firstname John
2 1 lastname Doe
3 2 firstname Justin
4 2 lastname Case
Now I would like to know how I get this view:
ID hash firstname lastname
================================
1 abc John Doe
So if I add an addtional entry in the USER_FIELD table with a key "email" I get a new column in the last result
Is this even possible just in MySQL or do I have to go and alter the result in PHP?
Is this even a good DB design or should I drop this an go with a different (which one?)