I am trying to delete all records from a table called user_enrole.I am using this query
DELETE * FROM user_enrole
I think syntax of my query is not wrong but it is giving me error saying
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '* FROM user_enrole' at line 1
I have doubled check my syntax i am not able to figure out what is going wrong can someone point out please.
Is it occuring because of the relationship this table has with use table or what?
Solution. By default, MySQL workbench is started in safe mode, and can't update or delete, without a “WHERE” condition, see the error message. To fix it, in menu, selects “Edit” -> “Preferences” -> “SQL Queries”, uncheck the “Safe Updates” checkbox. Done, try reconnect and issue the delete command again.
You can specify multiple tables in a DELETE statement to delete rows from one or more tables depending on the condition in the WHERE clause. You cannot use ORDER BY or LIMIT in a multiple-table DELETE .
You don't need to use the asterisk in a delete. Just do DELETE FROM user_enrole
to delete all records.
If you want to delete specific records filtered by one or more conditions, you will specify those conditions in the WHERE
clause, like so:
DELETE FROM user_enrole
WHERE somecolumn > 1
AND anothercolumn = 'Username'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With