DELETE IF EXIST `#__menu`.*
FROM `#__menu`
LEFT JOIN `#__extensions` ON `#__extensions`.`name` = 'com_view'
WHERE `#__menu`.`component_id` = `#__xtensions`.`extension_id`
AND `#__menu`.`alias` = 'view-sites' AND `#__menu`.`path` = 'view-sites' AND `#__menu`.`title` = 'View sites';
What is wrong in my sql? I think the problem is in IF EXIST, but i could not figure out how to use it on row.
When you’re deleting rows from a table, you don’t need to use
IF EXISTS– you’re using aWHEREclause, so if it exists – it will be deleted.Try changing your query to:
Also, you don’t need to specify “`#__menu
.*`` (the columns) to be deleted - you'll just needDELETE FROM…`. Check out here for more info regarding the syntax.