Select database query in MySQL
Selecting MySQL Database
October 22, 2020 – 11:25 am

It is very simple to select a database from the mysql> prompt. You can use the SQL command use to select a database.
Example
Here is an example to select a database called TUTORIALS −
[root@host]# mysql -u root -p Enter password:****** mysql> use TUTORIALS; Database changed mysql>
Now, you have selected the TUTORIALS database and all the subsequent operations will be performed on the TUTORIALS database.
NOTE − All the database names, table names, table fields name are case sensitive. So you would have to use the proper names while giving any SQL command.
Selecting a MySQL Database Using PHP Script
PHP provides function mysql_select_db to select a database. It returns TRUE on success or FALSE on failure.
Syntax
bool mysql_select_db( db_name, connection );
S. No. | Parameter & Description |
---|---|
db_name | Required − MySQL Database name to be selected |
connection | Optional − if not specified, then the last opened connection by mysql_connect will be used. |
Source: www.tutorialspoint.com
Related Posts