Use content of fieldnames in query..

Posted by rokdd on Stack Overflow See other posts from Stack Overflow or by rokdd
Published on 2010-03-13T14:30:31Z Indexed on 2010/03/13 14:35 UTC
Read the original article Hit count: 177

Filed under:
|

Hi,

i have three mysql tables:

Table 456
id | binder | property1
1 | b | hello
2 | b | goodbye
3 | a | bonjour
Table binder
id | binder | tableid1 | tableid2
1 | a | 23 | 456
2 | b | 21 | 456
3 | c | 45 | 42
Table 21
id | property1 | data..
1 | goodbye | data about goodbye..
2 | ciao | data about ciao..

So first i want to select in binder the binder i need to get the tablesname where data is stored. So i need to select table by a fieldname in this case the fieldname is tableid1 and would have the content 21 so that i have to look in 21. AND it should be property 1 from table 456 and table 21 the same... i am using php and already tried with union and subquerys but it seems that i am to silly to prepare such query!

© Stack Overflow or respective owner

Related posts about mysql

Related posts about php