What it means by 'no database selected' is that you're trying to execute that query on... well, nothing, really <_<
You need to select a database by executing a 'use' query
(ie: if your database is Hello, you'd execute 'use Hello;' (without the quotes)). It doesn't have to be the one particularly stated earlier, just so long as you use one and select the database.