I've got a data schema like this:
cp
id te su
1 7 2
2 7 1
3 6 8
cl
id cp st
1 2 5
2 2 6
3 1 6
us
id na
.. ..
5 Joe
6 Mike
7 Tina
.. ..
I want to run a php function foo($te)
with foo(7)
to output data like this from mySQL
[0]
su: 1
st_list:
[0]
id:6
na:Mike
[1]
su: 2
st_list:
[0]
id:5
na:Joe
[1]
id:6
na:Mike
I want to know how best to do this. Right now I'm able to use JOINs, but the result looks like this
[0]
su: 1
st_id:6
st_na:Mike
[1]
su: 2
st_id:5
st_na:Joe
[3]
su: 2
id:6
na:Mike
The su:2
is repeated... obviously that isn't a problem in this example, the problem is that in the real thing that su
represents a lot more data, that i'll be getting through "this" (whatever answer I choose) method.
EDIT: I hope you understand what I'm asking... I know a lot of you guys are way more knowledgable in mySQL and development in general than me, so that's why i'm asking in such a plain (I HAVE THS----> WANT THIS) way, because I think if I asked any more specifically I would end up making assumptions about the way it should run). I want an effecient solution, because this data is being used to populate search results.
Thanks!!!!!!!!!!