Sure, the data table could look like the table below.
So, for example, I need to return all the data in rows where column A is q and column B is r.
SELECT * FROM data WHERE row IN ( SELECT row FROM data WHERE col = 'A' AND value = 'q' ) AND row IN (SELECT row FROM data WHERE col = 'B' AND value = 'r' );
Which in this case would return all columns from only row 1.
Not horrible, but a little messy. What makes it horrible is that the data table is really created with something like
SELECT x.row, x.col, y.value FROM x INNER JOIN ( SELECT max(index), value FROM z GROUP BY value ) AS y ON x.index = y.index
which I really don't want to substitute three times into the first query.
Main Topics
Browse All Topics





by: matthewrhoadesPosted on 2008-07-25 at 13:36:15ID: 22092092
Could you include a couple records from each table? With the variable column and table names it is a little bit difficult to interpret. Sounds to me like you are going to be looking for a join statement to me, possibly to a system table if you are trying to determine column names.