Home > Enterprise >  Delete rows with symbol '?' at the end using sql query
Delete rows with symbol '?' at the end using sql query

Time:04-25

I want to delete rows with join two tables that contains phone number which end with symbol '?'. The rows are shown just like the picture below:

This is my query. But it shows syntax error #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'AS A JOIN maid_3 AS B ON A.id_user = B.id_user WHERE notel LIKE '%?'' at line 1

DELETE FROM `maid_2` AS A 
JOIN `maid_3` AS B 
    ON A.id_user = B.id_user 
WHERE notel LIKE '%?'

enter image description here

What's wrong with my query?

CodePudding user response:

Try this:

DELETE A 
FROM `maid_2` AS A 
JOIN `maid_3` AS B 
ON A.id_user = B.id_user 
WHERE notel LIKE '%?'

You are trying to delete data when there are multiple tables present in the delete query and in MariaDB there is Delete Syntax for Multiple-Table in which you have to mention the table from which rows need to be deleted:

DELETE [LOW_PRIORITY] [QUICK] [IGNORE]
tbl_name[.*] [, tbl_name[.*]] ...
FROM table_references
[WHERE where_condition]

For more info you can go through below link:

https://mariadb.com/kb/en/delete/
  • Related