List:General Discussion« Previous MessageNext Message »
From:Richard Mixon (qwest) Date:July 27 2004 2:36pm
Subject:RE: How to show comments/annotations in MySQL client output
View as plain text  
Harald Fuchs wrote:
> In article <4105E556.5010305@stripped>,
> Michael Stassen <Michael.Stassen@stripped> 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

Thread
How to show comments/annotations in MySQL client outputqwest)26 Jul
  • Re: How to show comments/annotations in MySQL client outputMichael Stassen27 Jul
  • Re: How to show comments/annotations in MySQL client outputHarald Fuchs27 Jul
    • RE: How to show comments/annotations in MySQL client outputqwest)27 Jul
      • RE: How to show comments/annotations in MySQL client outputPKeane27 Jul
        • RE: How to show comments/annotations in MySQL client outputqwest)27 Jul
      • Re: How to show comments/annotations in MySQL client outputMichael Stassen27 Jul
        • Re: How to show comments/annotations in MySQL client outputMichael Stassen27 Jul
          • RE: How to show comments/annotations in MySQL client outputqwest)27 Jul
            • Re: How to show comments/annotations in MySQL client outputMichael Stassen27 Jul
              • Re: How to show comments/annotations in MySQL client outputPaul DuBois28 Jul
                • Re: How to show comments/annotations in MySQL client outputMichael Stassen28 Jul
                  • RE: How to show comments/annotations in MySQL client outputqwest)28 Jul
      • Re: How to show comments/annotations in MySQL client outputMarkus Grossrieder27 Jul
        • RE: How to show comments/annotations in MySQL client outputqwest)27 Jul
Re: How to show comments/annotations in MySQL client outputMichael Stassen27 Jul