I've tried several methods of trying to implement this query but to no avail. Any help would be greatly appreciated What I'm trying to do: I have a temp table i've built up with names, values and data types. I need to query this against a table which has an index title field, which matches to my temp table names column, and then the other data could be in one of four columns in the table, dependant on the indexes data type. Once I have a match on the correct indexname and datatype I can then compare their values. Regards Mike [<b>edited by:</b> katali at 1:16 PM (GMT -8) on 24 Aug 2009] A clearer version of what I want and some example SQL is noted a few comments below and I've removed the spaghetti code which was here before for ease of reading.