If I do this
ALTER TABLE cp8_sales_order_flat
ADD CONSTRAINT fk_customer
FOREIGN KEY (customer_id)
REFERENCES customers(id)
ON DELETE SET NULL
ON UPDATE CASCADE;
it will say it cant add foreign key error 1215
if I just write
ALTER TABLE sales_flat_order
ADD FOREIGN KEY (customer_id) REFERENCES customers(id);
then it adds the FK, and the constraint, but it is set as: restrict.
it seems to me that this would allow correct select join queries, but not deletes or updates. Why is this? any fix?
UPDATE
One of the reasons may also be that the column you are using for ON DELETE SET NULL is not defined to be null. So make sure that the column is set default null.
This is the one I think, as I checked everything else, type, collation, length, attribute