Not sure if I get it...


I was in MySQL writing my ‘first’ query and when I was done an error came up:

ERROR 1046 (3D000): No Database Selected

Wasn’t I creating a database?

I started with the ganeric “CREATE TABLE”

Was I suppose to do something prior to this that I missed?


HOW were you in MySQL? Command line? Via phpMyAdmin? Using some other client like SQL Front or SQLYog?

And NO CREATE TABLE should NOT be the first command. You need to either CREATE DATABASE DatabaseName (where the individual tables will go) or USE DatabaseName

If you CREATE DATABASE DatabaseName you still need to USE DatabaseName because CREATE does not automatically imply the USE command.


I was in the command line…

That makes sence… I created the database, but on the next line I was “Creating a table”. Instead I have to use the “USE DATABASE” command and then use “CREATE TABLE”?

Is there a MySQL for begginers web site I can go to? I really like the Sam’s Teach Yourself book I have, but it expects you to alreasdy know certain things that I’m not too familiar with yet.

Thanks so much for the help by the way!


At ALL times you will need USE databasename in order to work with tables (i.e. queries such as CREATE TABLE, SELECT, UPDATE, etc). However, also make sure that the database you USE, exists in MySQL (can’t use a non-existent database :wink: )