Is it possible to write a where statement that uses the column name that has been assigned to the column rather than the column name that actually exists? The entire table is created dynamically with the column names stored in another table. I have a function that allows users to add filters to an jobect before retrieving the set of data that goes with it.
Example of what I am trying:
SELECT id,
col1 as [description],
col2 as [date1],
col3 as [image],
col4 as [date2],
col5 as [link],
col6 as [location],
col7 as [price],
col8 as [title]
FROM tableName
WHERE [title] = 'Lemons'
Make your original query a subquery:
SELECT *
FROM (
SELECT id,
col1 as [description],
col2 as [date1],
col3 as [image],
col4 as [date2],
col5 as [link],
col6 as [location],
col7 as [price],
col8 as [title]
FROM tableName
) as subquery
WHERE [title] = 'Lemons'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With