If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Beginners question Aliased Columns

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-09-04, 04:29
Gary Taylor Gary Taylor is offline
Registered User
 
Join Date: Feb 2004
Posts: 1
Beginners question Aliased Columns

Hi I'm having trouble in referring to an aliased column name in my query.

SELECT 1 as v1, v1+1 as v2;

Can anyone tell me how to do this please?
Reply With Quote
  #2 (permalink)  
Old 02-09-04, 09:50
aus aus is offline
Registered User
 
Join Date: Oct 2003
Location: Denver, Colorado
Posts: 137
Re: Beginners question Aliased Columns

Try this instead:
Code:
SELECT @v1:=1 as v1, @v1+1 as v2;
This will assign the user variable @v1 the value of v1 for each record. I am not sure why you cannot refer to aliased columns within the column selection portion of the statement.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On