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.
解决方案
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:
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":
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):