I write a query when doing a tutorial Agile web application development with yii. I was trying to alter a table with this query and got this error in phpmyadin
ALTER TABLE 'tbl_issue' ADD CONSTRAINT 'FK_issue_project' FOREIGN KEY
('project_id') REFERENCES 'tbl_project' ('id') ON DELETE CASCADE ON
UPDATE RESTRICT
> #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 ''tbl_issue' ADD CONSTRAINT 'FK_issue_project' FOREIGN KEY
> ('project_id') REFERE' at line 1
Can anyone help please?
The problem may be that you’re using single quotes instead of backticks as enclosing characters for table, field and index names.
Try:
ALTER TABLE `myTable` ADD CONSTRAINT `myConstraint`...(in case the posted code is actually what you used for your statement executed through phpMyAdmin).