MySQL Commands

Handy MySQL Commands Description Command To login (from unix shell) use -h only if needed. [mysql dir]/bin/mysql -h hostname -u root -p Create a database on the sql server. create database [databasename]; List all databases on the sql server. show databases; Switch to a database. use [db name]; To see all the tables in the db. show tables; To see database’s field formats. describe ; […]

SQL – Select example

Following are example of SQL SELECT statements: To select all columns from a table (Customers) for rows where the Last_Name column has Smith for its value, you would send this SELECT statement to the server back end: SELECT * FROM Customers WHERE Last_Name=’Smith’; +———+———–+————+ | Cust_No | Last_Name | First_Name | +———+———–+————+ | 1001 | Smith | John | | 2039 | Smith | David | | 2098 | Smith | Matthew | […]