Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Setting Arrays for a query

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hello... This is what I am doing....

SELECT col1, col2, col3, col4, col5, (col1+col2+col3) FROM table WHERE (col1+col2+col3) < any_number and col1 = 'any_value' ORDER BY (col1+col2+col3);

What I wouuld like to do is place the result of the formula (col1+col2+col3) into an array to be used within the query.. I am using trig funcions in the real formula and I want to cut down on cpu time... Any suggestions... ??

Thanks in advance.
Kurt
 
I'm not sure I fully understand what you're asking for. Are you sure that &quot;array&quot; is the correct term? If so, what you want the elements of the array to represent? If you're just looking to apply a term to access the anonymous column that's created by the function, use the AS keyword. So your statement looks like:

SELECT col1, col2, col3, col4, col5, (col1+col2+col3) AS addedCols FROM table where (col1+col2+col3) < any_number and col1 = 'any_value' ORDER BY addedCols;

Perhaps this helps?

brendanc@icehouse.net
 
OK.... array was not the correct mysql term.. The proper term probably would have been variable.. In the example from my original question... I would like to assign to a variable the value of (col1+col2+col3). Then use the variable in a query instead of doing the function again and again and again.

Thanks again.

kmrichards.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top