given a table 'my_table' with columns col1,col2.
Is it possible to write a query like this
SELECT col1 as my_alias,col2 FROM my_table WHERE my_alias = 'value'
I have tried it but get an unknown column 'my_alias' in where clause.
For the curious, the reason I am doing this is:
I have a table with a composite primary key. When I retrieve information from that table I concatenate the cols that make up the primary key into an Id which can then be used in my url's to identify particular records. Then when I want to return only the given record I select the record where it is = my alias. Not sure if this is a good idea, feel free to comment.
Note: The standard way to do this query is:
SELECT col1 as my_alias,col2 FROM my_table WHERE col1 = 'value';