I'm using 4.0.20. System is a mysql client command (i.e., not SQL). See <http://dev.mysql.com/doc/mysql/en/mysql_Commands.html> for the list of mysql client commands, or enter 'help' or '?' at the mysql prompt.

Michael

Markus Grossrieder wrote:

Michael,

which version are you using ? I didn't find SYSTEM in the manual ...

Thanks, Markus

----- Original Message ----- From: "Michael Stassen" <[EMAIL PROTECTED]>
To: "Richard Mixon (qwest)" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Tuesday, July 27, 2004 6:09 PM
Subject: Re: How to show comments/annotations in MySQL client output




One more thought: Your mention of echo jogged my memory.  You can use SYSTEM
to pass what follows to the system and display the result.  So,

  SYSTEM echo "## The following output should only contain two rows.";

results in

  ## The following output should only contain two rows.

assuming echo is a command which makes sense to your system.

Michael


Michael Stassen wrote:



Richard Mixon (qwest) wrote:


Harald Fuchs wrote:


In article <[EMAIL PROTECTED]>,
Michael Stassen <[EMAIL PROTECTED]> writes:



Richard Mixon (qwest) wrote:


I run some mysql command files (just SQL statements in a file I read
from standard input) and need to place some annotiations/comments
in the output. If I place standard SQL comments ("-- comment text")
or MySQL comments ("# comment text") they do not show up in the
mysql client output. Well, in a way that makes sense - they are
"comments".
I have tried using "select ' comment text' ;" and that works, but I
get many, many lines instead of my one simple annotation - e.g.:
-------------- select "First comment ..."
--------------
+-------------------+


First comment ... |


+-------------------+


First comment ... |


+-------------------+
1 row in set (0.00 sec)
Any/all ideas are appreciated - Richard


SELECT "First comment ...";


will give exactly the output you show, but


SELECT "First comment ..." FROM sometable;


will return that string once for each row of the table.  Is that what
you're doing?


I guess he's talking about the column headers produced by the "mysql"
client program.  These can be suppressed by using "mysql -N".



Michael/Harald,

Thanks for the tip. But:

1) Yes, I am just issuing: SELECT "First comment ...";
and
2) The problem is that instead of getting a single line of text (i.e. my
"annotation/comment"), I get many, for example the command "select
"COMMENT 3";" produces the following (even using the -N flag when I
startup mySQL):
 --------------
 SELECT "COMMENT 3"
 --------------

 +-----------+
 | COMMENT 3 |
 +-----------+
 1 row in set (0.00 sec)
The problem with "-N" is that is suppresses all of the headers. What I
really need is an "echo" or "print" command.

The idea is to guide the reader of the mysql client output with some
comments. The SQL might look like the following:
 SELECT "The following output should only contain two rows for status
...";
 SELECT status,count(*) FROM PoClass GROUP BY status;
 SELECT "The following output should only contain three rows for status
...";
 SELECT status,count(*) FROM PoClassMeasurement GROUP BY status;

Thank you - Richard


Well, it's not exactly what you want, but you could use an alias to give
each comment a standard header:

 SELECT 'The following output should only contain two rows for status.'
 AS COMMENT;

+---------------------------------------------------------------+
| COMMENT                                                       |
+---------------------------------------------------------------+
| The following output should only contain two rows for status. |
+---------------------------------------------------------------+
1 row in set (0.00 sec)

You still get some extra lines, but perhaps that looks a little better.
You could also change the alias according to the type of comment:

 SELECT 'The following output *must* contain only two rows!'
 AS `WARNING!`;

+----------------------------------------------------+
| WARNING!                                           |
+----------------------------------------------------+
| The following output *must* contain only two rows! |
+----------------------------------------------------+
1 row in set (0.00 sec)

Michael




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

http://lists.mysql.com/[EMAIL PROTECTED]



---------------------------------------- My Inbox is protected by SPAMfighter 1396 spam mails have been blocked so far. Download free www.spamfighter.com today!




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



Reply via email to