There be a situation when there are different databases present and you have to select one of them to work on. So after MySql connection you can do the following things:
Selecting MySQL Database from Command Prompt:
This is very simple to select a particular database from mysql> prompt. You can use SQL command use to select a particular database.[bha size=’468×60′ variation=’01’ align=’none’]
Here is an example to select database called “DATABASE TUTORIALS”:[[email protected]]# mysql -u root -p
mysql> use DATABASE TUTORIALS;
As you select “DATABASE TUTORIALS” database and all the subsequent operations will be performed on DATABASE TUTORIALS.
Selecting MySQL Database Using PHP Script:
PHP provides function mysql_select_db to select a database. It returns TRUE on success or FALSE on failure.
bool mysql_select_db( db_name, connection );
|db_name||MySQL Database name is to be selected by the user|
|connection||Optional – then last opened connection by mysql_connect will be used.|
How to select a database.