#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2008
    Posts
    71
    Rep Power
    7

    Format query output at mysql prompt?


    I'm just wondering if there's a way to print out the results from a query conducted at the mysql prompt so that it's a little easier to read.

    Rather than:

    field a | field b | field c
    +---------------+-------------+-------------+
    | 100 | abcedef | ghijklmnop

    is there a way to print to screen so that it looks like this:

    field a | 100
    field b | abcedef
    field c | ghijklmnop
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2007
    Location
    Purley, Surrey
    Posts
    248
    Rep Power
    37
    Originally Posted by takeiteasyonme
    I'm just wondering if there's a way to print out the results from a query conducted at the mysql prompt so that it's a little easier to read.

    Rather than:

    field a | field b | field c
    +---------------+-------------+-------------+
    | 100 | abcedef | ghijklmnop

    is there a way to print to screen so that it looks like this:

    field a | 100
    field b | abcedef
    field c | ghijklmnop
    Not sure it's any easier to read but try terminating with a \G instead of a ; for that type of display
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2008
    Posts
    71
    Rep Power
    7
    Perfect! Thanks!
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    1
    Rep Power
    0
    MySQL query ouput can be formatted in better way using \P less -S option as below:

    mysql> \P less -S
    mysql> <SELECT QUERY>
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    1
    Rep Power
    0
    Is there a way to format MySQL query output that is printed to a browser window? Like an HTML and JavaScript website that uses php to make MySQL queries. I would like to format my output into easily readable HTML tables and use some CSS.

    Thanks in advance for any suggestions!

IMN logo majestic logo threadwatch logo seochat tools logo