March 9th, 2009, 08:00 AM
Where value is like field name
I'm trying to write a query that looks at a value of a record and returns a value based on the name of the field. Basicly I have a language table that contains the days of the week in a number of diffrent languages, which has field names like DAY1 DAY2 ... DAY7 and another table that has a day field with the value like 1,2...7. What I want to achieve is to look at the name of the field and return its value.
Does anyone know of a way to do this?
On the off chance that I have been helpfull please click this
March 9th, 2009, 09:26 AM
I'm sorry I dont understand what you are trying to achieve. Any chance you could post a sample of your data so we can see what is going on?
March 9th, 2009, 09:45 AM
Yeah it does sound pretty confusing, this is my data structure:
| LANG | DAY1 | DAY2 | DAY3 | etc
| E | Mon | Tue | Wed |
| Some Data | Some Data | DAY |
| DATA | DATA | 1 |
So in this case I'd want to return the day 1 so the query would need to look at the field names of the language table and return the value where field is day1.
Does this help?
March 10th, 2009, 04:25 AM
I've wrote a query that describles what I want to do, it doesnt work of course but I've found the SQL keyword COLUMNS that sounds like it does what I want.
What I want this to do is to return the value in the record of the F_LANGUAGE table where its column name is like that FLAT_CHOVERDAY field.
SELECT FLAT_CHOVERDAY FROM F_APARTMENTS, F_LANGUAGE WHERE (FLAT_CHOVERDAY LIKE COLUMS FROM F_LANGUAGE) AND (FLAT_CHOVERDAY = 1) ;
Does this help at all?