Nifty idea, but it doesn't work for me:

$ cat <<EOF | mysql test
> \P cat /dev/null
> SELECT @id := id FROM users ORDER BY id DESC LIMIT 1;
> \n
> SELECT * FROM users WHERE id = @id;
> EOF
@id := id
3
PAGER set to stdout
id      first   last    email
3       testy   mctest  [EMAIL PROTECTED]

Ideally, the output would look like:

$ cat <<EOF | mysql test
> /* MAGIC */
> SELECT @id := id FROM users ORDER BY id DESC LIMIT 1;
> SELECT * FROM users WHERE id = @id;
> EOF
id      first   last    email
3       testy   mctest  [EMAIL PROTECTED]

I suppose a JOIN would work, instead:

$ cat <<EOF | mysql test
> CREATE TEMPORARY TABLE last_id SELECT id FROM users ORDER BY id DESC LIMIT
1;
> SELECT users.* FROM users JOIN last_id USING (id);
> EOF
id      first   last    email
3       testy   mctest  [EMAIL PROTECTED]

but using @id seems less, well, wasteful.

____________________________________________________________
Eamon Daly



----- Original Message ----- 
From: "Diana Soares" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, September 02, 2004 9:38 AM
Subject: Re: Suppression of result in SELECT @temp := column?


> I didn't understand the problem very well, but maybe disabling the pager
> before that query where you set @temp, do the query, setting the pager
> to its default value and then do the  "next statement to produce the
> actual result."
>
> \P cat /dev/null
> SELECT @temp := columnID FROM table WHERE column = whatever LIMIT 0,1
> \n
> SELECT ....
>
> -- 
> Diana Soares
>
>
> On Tue, 2004-08-31 at 23:00, Eamon Daly wrote:
> > Did anyone ever follow up on this question? I'm looking for
> > the answer, too.
> > ____________________________________________________________
> > Eamon Daly
>
> > ----- Original Message ----- 
> > From: <[EMAIL PROTECTED]>
> > To: <[EMAIL PROTECTED]>
> > Sent: Wednesday, August 25, 2004 9:16 AM
> > Subject: Suppression of result in SELECT @temp := column?
>
> > > Is there any way to not sending the result of a user variable
assignment
> > > to the client?
> > > I.e. Suppress the result of;
> > >
> > > SELECT @temp := columnID FROM table WHERE column = whatever LIMIT 0,1
> > >
> > > ...since I only use @temp in my next statement to produce the actual
> > result.


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to