I have a site that stores <select> options in a number of tables, and extracts all of the relevant ones depending on the individual page. At the moment, I wind up with a query like this: SELECT foo FROM foo_tbl;SELECT bar FROM bar_tbl;etc. It's not really a bad problem, but I have to iterate over each select result individually.

I'd like to extract all of them into a single grid, then do something like

If I use a query like SELECT DISTINCT f.foo, b.bar FROM foo_tbl AS f, bar_tbl AS b, I wind up with every possible combination of rows (first foo first bar, first foo second bar, second foo first bar, second foo second bar, etc etc).

Is there a way to do a select like that and having only once instance of each element in a column, and filling the rest of the rows in the column with nulls?

Your proposed solution is bad, especially if you have different numbers of options per type. You should either run multiple queries, or return a result UNIONed, with the columns being [Type, Value]
–
gahooaFeb 4 '10 at 5:33

NICE ... now if the first argument showed what table the data came from, then monksp's request would be answered! I've added that to your answer, feel free to rollback if you don't like it!
–
lexuFeb 4 '10 at 5:42