Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySQL error "empty string given as argument for ! character"

Tags:

sql

mysql

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.

like image 530
user3507584 Avatar asked Nov 25 '14 17:11

user3507584


Video Answer


1 Answers

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

like image 126
h2ooooooo Avatar answered Sep 17 '22 14:09

h2ooooooo