I'm using PuTTY to run:
mysql> SELECT * FROM sometable;
sometable
has many fields and this results in many columns trying to be displayed in the terminal. The fields wrap onto the next line so it is very hard to line up column titles with field values.
What solutions are there for viewing such data in terminal?
I don't have nor want access to phpMyAdmin - or any other GUI interfaces. I'm looking for command-line solutions such as this one: Save MySQL Query results into text or CVS file
To select first 10 elements from a database using SQL ORDER BY clause with LIMIT 10. Insert some records in the table using insert command. Display all records from the table using select statement. Here is the alternate query to select first 10 elements.
In MySQL the LIMIT clause is used with the SELECT statement to restrict the number of rows in the result set. The Limit Clause accepts one or two arguments which are offset and count. The value of both the parameters can be zero or positive integers.
To select multiple values, you can use where clause with OR and IN operator.
To select multiple columns from a table, simply separate the column names with commas! For example, this query selects two columns, name and birthdate , from the people table: SELECT name, birthdate FROM people; Sometimes, you may want to select all columns from a table.
Terminate the query with \G
in place of ;
. For example:
SELECT * FROM sometable\G
This query displays the rows vertically, like this:
*************************** 1. row *************************** Host: localhost Db: mydatabase1 User: myuser1 Select_priv: Y Insert_priv: Y Update_priv: Y ... *************************** 2. row *************************** Host: localhost Db: mydatabase2 User: myuser2 Select_priv: Y Insert_priv: Y Update_priv: Y ...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With