List:MySQL on Win32« Previous MessageNext Message »
From:Christopher R. Jones Date:June 1 2000 12:46pm
Subject:Re: Command line tool problem
View as plain text  
Here is how I do it:
create a text file with the select statement, for example, "select1.sql"
The from the command line:
c:\example> mysql -u user -ppass userdatabase < select1.sql > output1.dat
The you can edit output1.dat.  The results, in the output file, may span 
more than 1 line, you need to edit the lines to a format that works for you.

Of course, the other way to do it is to create a quick perl CGI script and 
send the output through the WEB server to an HTML document.  This works 
very well on NT using Activestate Perl, DBI and Personal Web Server.



>Hi,
>
>I'm new to MySQL and I use MySQL-Shareware 3.22.34 on a NTWKS4.0-SP4 
>machine. When I work with the MySQL command line tool(mysql.exe), if I 
>issue a query to a table that contains varchar fields, the output is 
>mangled. Somehow, the output field length is smaller than the actual size 
>of the field and the last characters are written over the beginning 
>characters. The example below is more explicit:
>
>###### Begin of screen capture ##########################
>mysql> describe telefon_abonati;
>+-------+-------------+------+-----+---------+-------+
>| Field | Type        | Null | Key | Default | Extra |
>+-------+-------------+------+-----+---------+-------+
>| numar | varchar(30) |      | PRI |         |       |
>| nume  | varchar(50) |      | MUL |         |       |
>+-------+-------------+------+-----+---------+-------+
>2 rows in set (0.00 sec)
>
>mysql> select nume from telefon_abonati order by nume desc limit 10;
>+-----------------------+
>| nume                  |
>+-----------------------+
>   |VOLINSCHI VIRGINIA
>  |ZVERGINSCHI GHEORGHE
>         |RNELIA
>         |RELIAN
>            |
>          |OSIF
>          |OLAE
>         |EZAREL
>        |U VASILE
>        |U VASILE
>+-----------------------+
>10 rows in set (0.73 sec)
>###### End of screen capture ############################
>
>the actual fields are:
>ZVOLINSCHI VIRGINIA
>ZVERGINSCHI GHEORGHE
>ZUZU CORNELIA
>ZUZU AURELIAN
>ZUZA EUGEN
>ZUSKAN IOSIF
>ZUPU NICOLAE
>ZUGUN CEZAREL
>ZUGRAVU VASILE
>ZUGRAVU VASILE
>
>Also, if I try to use concat on varchar fields the output is similarly 
>mangled:
>
>###### Begin of screen capture ##########################
>mysql> select concat(nume,'123') from telefon_abonati order by nume desc 
>limit 10;
>+--------------------------+
>| concat(nume,'123')       |
>+--------------------------+
>123  |INSCHI VIRGINIA
>123 |RGINSCHI GHEORGHE
>123        |LIA
>123        |IAN
>123           |
>123         |F
>123         |E
>123        |REL
>123       |ASILE
>123       |ASILE
>+--------------------------+
>10 rows in set (0.73 sec)
>
>mysql> select concat(nume,'123') from telefon_abonati order by nume desc 
>limit 10
>     -> ego
>*************************** 1. row ***************************
>123cat(nume,'123'): ZVOLINSCHI VIRGINIA
>*************************** 2. row ***************************
>123cat(nume,'123'): ZVERGINSCHI GHEORGHE
>*************************** 3. row ***************************
>123cat(nume,'123'): ZUZU CORNELIA
>*************************** 4. row ***************************
>123cat(nume,'123'): ZUZU AURELIAN
>*************************** 5. row ***************************
>123cat(nume,'123'): ZUZA EUGEN
>*************************** 6. row ***************************
>123cat(nume,'123'): ZUSKAN IOSIF
>*************************** 7. row ***************************
>123cat(nume,'123'): ZUPU NICOLAE
>*************************** 8. row ***************************
>123cat(nume,'123'): ZUGUN CEZAREL
>*************************** 9. row ***************************
>123cat(nume,'123'): ZUGRAVU VASILE
>*************************** 10. row ***************************
>123cat(nume,'123'): ZUGRAVU VASILE
>10 rows in set (0.73 sec)
>###### End of screen capture ############################
>
>How can I solve this problem? It is very hard to debug my programs if I 
>don't have a good,
>quick query tool. I could write my own query tool but this would be very 
>time-expensive and
>I'm running out of time.
>
>
>-- Catalin Borcea --


Christopher R. Jones, P.Eng.
14 Oneida Avenue
Toronto, Ontario M5J 2E3
Tel. 416 203-7465
Fax. 416 203-3044
Email cj@stripped


Thread
Command line tool problemCatalin Borcea1 Jun
  • Re: Command line tool problemChristopher R. Jones1 Jun
  • Re: Command line tool problemSinisa Milivojevic1 Jun
  • Re: Command line tool problemTonci Grgin27 Jun