MySQL Forums
Forum List  »  Newbie

using variables in select statements
Posted by: Neil Knapp
Date: August 23, 2004 04:17PM

when I attempt to use a variable in a select statement it returns the value of the variable rather than the contents of the column with the variable name.

e.g.

if there is 1 row in the column1 column containing the word 'hello'

set @t1='column1;'

select @t1 from table;

this returns

---------
| '@t1' |
---------
|column1|
----------

instead, I was hoping it would return 'hello', so instead of returning the value of the column, it is returning the value of the variable.

Is there anyway to combat this please?

Regards

Neil

Options: ReplyQuote


Subject
Written By
Posted
using variables in select statements
August 23, 2004 04:17PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.