19.10.2015, 17:27
(
Последний раз редактировалось Evocator; 19.10.2015 в 19:25.
)
Hi, sorry for the bump. Again facing problems with the query:
CREATE TABLE `Table1` (`Field` INT(11) NOT NULL, `Field1` VARCHAR(21) NOT NULL, PRIMARY KEY (`Field`));
CREATE TABLE `Table2` (`Field1` VARCHAR(21) NOT NULL, `Field` INT(11) NOT NULL DEFAULT '0');
ALTER TABLE `Table2`
ADD FOREIGN KEY (`Field1`)
REFERENCES `Table1` (`Field1`)
ON UPDATE CASCADE
ON DELETE CASCADE
SQL Error (1005): Can't create table 'SAMP_294.#sql-1673_41aa' (errno: 150) Foreign key constraint is incorrectly formed *
EDIT: Looks like my `Field1` in `Table1` should be a unique index - sadly this wont work as i already have Field as a primary key.
CREATE TABLE `Table1` (`Field` INT(11) NOT NULL, `Field1` VARCHAR(21) NOT NULL, PRIMARY KEY (`Field`));
CREATE TABLE `Table2` (`Field1` VARCHAR(21) NOT NULL, `Field` INT(11) NOT NULL DEFAULT '0');
ALTER TABLE `Table2`
ADD FOREIGN KEY (`Field1`)
REFERENCES `Table1` (`Field1`)
ON UPDATE CASCADE
ON DELETE CASCADE
SQL Error (1005): Can't create table 'SAMP_294.#sql-1673_41aa' (errno: 150) Foreign key constraint is incorrectly formed *
EDIT: Looks like my `Field1` in `Table1` should be a unique index - sadly this wont work as i already have Field as a primary key.