I have a table called USERS, which has an index of certain nationalities as a string delimited by commas.
ID | NOMBRE | NACIONALIDAD
1 | JUAN | 1,2,3
2 | PEDRO | 1,2
3 | JOSE | 1,3
I have my table of NATIONALITIES
ID | NACION
1 | Ruso
2 | Español
3 | Brasileño
How could the INNER JOIN make me bring the names? I tried:
SELECT U.* FROM USERS U INNER JOIN NACIONALIDADES N ON U.NACIONALIDAD IN ( N.ID )
I hope an exit as well as
ID | NOMBRE | NACIONALIDAD
1 | JUAN | Ruso,Español,Brasileño
2 | PEDRO | Ruso,Español
3 | JOSE | Ruso,Brasileño
I am using PHP, I could first obtain an initial array of nationalities and then compare the indexes, but I would like to know if there is a direct query with the database.
Thanks