472,127 Members | 1,984 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,127 software developers and data experts.

Seeking silence!

I just want to assign a variable from a query that returns a single value
result.
The problem is that the following will also emit (print) the result to the
terminal as a side effect.

SELECT @SomeVar := SomeFieldCalculation
FROM ...
WHERE ...

Is there not a simple way to accomplish this silently. IOW - get SELECT to
shut up since it is merely assigning a variable for use further along. Or
is there some other assignment syntax I should use that doesn't involve the
verbose SELECT.

And yes - I do know I can redirect the output to oblivion.

I just think I must be missing something ;-)
Thomas Bartkus
Jun 22 '06 #1
1 1225
It's a bit of a hack, but you can do this:

set @somevar := ( select randomtext from random_table where ... );

Thomas Bartkus wrote:
I just want to assign a variable from a query that returns a single value
result.
The problem is that the following will also emit (print) the result to the
terminal as a side effect.

SELECT @SomeVar := SomeFieldCalculation
FROM ...
WHERE ...

Is there not a simple way to accomplish this silently. IOW - get SELECT to
shut up since it is merely assigning a variable for use further along. Or
is there some other assignment syntax I should use that doesn't involve the
verbose SELECT.

And yes - I do know I can redirect the output to oblivion.

I just think I must be missing something ;-)
Thomas Bartkus


Jun 26 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Ben Sehara | last post: by
12 posts views Thread by David | last post: by
3 posts views Thread by ad | last post: by
6 posts views Thread by Greg M | last post: by
3 posts views Thread by carthia | last post: by
3 posts views Thread by Jia Lu | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.