[EMAIL PROTECTED] wrote:
> Hi Richard,
>
> not exactly sure what you want but try using \G at the end of
> the select
> statements.
> Also try using UNION.
> e.g.
> select "Put your comment here","" UNION select field1, field2
> from table1
> group by field 1 \G
>
> You may get something that will work for you by messing with these
> options combined with suppressing headers?
>
> Peter Keane
> Trocaire
> Maynooth
> Ireland
>
> "Richard Mixon \(qwest\)" <[EMAIL PROTECTED]> wrote on 27/07/2004
> 15:36:45:
>
>> 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
Innovative idea, but does now quite do what I need. For the following
SQL input:
SELECT "COMMENT 1",""
UNION
SELECT status,count(*) FROM PoClass GROUP BY status
I end up with this output, loosing (replacing actually) my column
headers:
--------------
SELECT "COMMENT 1","" UNION SELECT status,count(*) FROM PoClass GROUP BY
status
--------------
+-----------+--+
| COMMENT 1 | |
+-----------+--+
| COMMENT 1 | |
| 1 | |
| 2 | |
+-----------+--+
3 rows in set (0.00 sec)
I'll either use the "AS" option or go to a scripting language.
Thanks - Richard
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]