5

I have a very simple query

select * 
from tablename 
where keyvar is not null 
order by keyvar

The query worked before but for some reason now I am getting an error:

Error:Error formatting SQL query: empty string given as argument for ! character

Anyone has any idea why I am getting this error? Any help hugely appreciated

PS: If I run the whole code again from scratch (creating the database, loading the csv file etc) the query works fine.

9
  • already checked it, I always google before asking... but it didn't work in my case :( Nov 25, 2014 at 17:16
  • Is it in the MySQL workbench?
    – h2ooooooo
    Nov 25, 2014 at 17:17
  • Yes, it is in the MySQL workbench 6.2. CE. And curiously enough, if I run the whole code again (creating the database, loading the csv file etc, the code works fine. Nov 25, 2014 at 17:20
  • 2
    It sounds like it isn't actually using the database (the same problem that the link I gave you says). Instead of selecting the database (that you mentioned doesn't work), how about using USE dbname; before your query?
    – h2ooooooo
    Nov 25, 2014 at 17:21

1 Answer 1

13

First of all, this is not a MySQL error - it's a MySQL Workbench error (you can see it in Oracle's source code here).

Secondly, you'll get this error when no database is selected. There's two ways you can select one.

Let's look at what it looks like when no databases are selected:

enter image description here

as you can see it's not bold. This can be easily fixed by double clicking on the database name, or right clicking and choosing "Set as Default Schema":

enter image description here
enter image description here

Should you still not see any database selected on the left side, you can force it by using the SQL command USE like so: USE `dbname`; (where dbname is your database name):

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.