jeudi 5 mars 2015

How do I replace IDs from multiple columns with the related data from the same external table?


I have two MySQL tables ( simplified ).


Table 'words' contains 'id' and 'word' fields. Table 'entities' has an 'id' field ( for each entity ) and then multiple columns that each contain word_id's from the words table ( word_id_0, word_id_1, word_id_2, etc. ).


I'd like to dump a bunch of rows from the 'entities' table and replace the word_id's with the words. Is there an easy way to do this with SQL?



go from: 1, 234, 456, 567
to: 1, word_234, word_456, word_567




Aucun commentaire:

Enregistrer un commentaire