i have two tables, one for users ( id, name, lastname ), and another for climbs ( id, name_of_climb, users_on_climb ).
due to simplicity of the php
code on the other end, i have the users_on_climb as a text that lists user ids delimited by comma ( so for example: 1,2,3 ; would mean users with id 1, 2 and 3 were on the climb ).
Now im trying to display this information in a friendly way, so im trying to make a query that would give me: name_of_climb, ALL users name and lastname.
I tried sub querying, but its beyond me how this could be done. I was thinking something like this ( obviously stringify isn't a real thing, but i hope you get the idea ):
select name_of_climb,stringify( select name,lastname from users where id in (climbs.users_on_climb) )
from climbs
Yes, the obvious solution is to simply run the php script to query the name,lastname for each row in a for loop( select name,lastname from users where user.id in (users_on_climb )
), but is there a way to do it without running queries in a loop?