Forgive me, I am new to mysql
I have this mysql table:
|ID|KeyID1|KeyID2|Param|Value|...
|asdf|1|2| ...
The KeyID1 and KeyID2 values exist another Table like this:
|KeyID|Real Name|
| 1 | Gordon
| 2 | Jason
I want to be able to join the two tables together such that I would have ID|Real Name1|Real Name2|Param|Value
what would i need to do in mysql? Would I need to duplicate another table?
edit: i can change the database design
This is a classic JOIN operation:
I’m assuming that your first table is called
mytableand that the name lookup table is callednametable, and I also removed the spaces from column names.Whenever you need to replace a foreign unique identifier by values from the corresponding lookup table, it’s time for a JOIN on that lookup table. If you do it multiple times from the same table, you can use aliases (
AS) to disambiguate which instance you are referring to.