MySQL Forums
Forum List  »  General

Re: remove pre and trailing '|' on mysql output
Posted by: Jonathan Stephens
Date: April 11, 2014 08:11AM

You can't really do that within the mysql client. It's intended to let you view the contents of tables and to help you test queries. It's not meant to be used as part of your applications.

The mysql client basically gives you two choices for output, horizontal and vertical.

You need to use some programming or scripting language with a MySQL API to provide you with unformatted data and use that language's string handling to format it the way you want it presented.

Another option is to pipe the output into a file, like this:

shell> mysql -uuser -ppass -e "SELECT RTRIM('from') FROM lang_translation WHERE lang=3 order by id" > myfile.txt

Then you can use whatever you prefer for text-processing to operate on the contents of the file, which shouldn't contain anything other than data, linefeeds, and tabs in any case IIRC.


cheers
jon.

Jon Stephens
MySQL Documentation Team @ Oracle

MySQL Dev Zone
MySQL Server Documentation
Oracle



Edited 1 time(s). Last edit at 04/11/2014 08:31AM by Jonathan Stephens.

Options: ReplyQuote


Subject
Written By
Posted
Re: remove pre and trailing '|' on mysql output
April 11, 2014 08:11AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.