GNU Info

Info Node: (mysql.info)USE

(mysql.info)USE


Next: DESCRIBE Prev: Basic User Commands Up: Basic User Commands
Enter node , (file) or (file)node

`USE' Syntax
------------

     USE db_name

The `USE db_name' statement tells MySQL to use the `db_name' database
as the default database for subsequent queries.  The database remains
current until the end of the session or until another `USE' statement
is issued:

     mysql> USE db1;
     mysql> SELECT count(*) FROM mytable;      # selects from db1.mytable
     mysql> USE db2;
     mysql> SELECT count(*) FROM mytable;      # selects from db2.mytable

Making a particular database current by means of the `USE' statement
does not preclude you from accessing tables in other databases.  The
example below accesses the `author' table from the `db1' database and
the `editor' table from the `db2' database:

     mysql> USE db1;
     mysql> SELECT author_name,editor_name FROM author,db2.editor
                WHERE author.editor_id = db2.editor.editor_id;

The `USE' statement is provided for Sybase compatibility.


automatically generated by info2www version 1.2.2.9