Skip to main content

SQL Reference

Create a table that auto deletes on other table deletion

CREATE TABLE tradie_postcode_covered (
    id INT AUTO_INCREMENT PRIMARY KEY,
    tradie_id INT,
    postcode INT,
    FOREIGN KEY (tradie_id) REFERENCES tradies(id) ON DELETE CASCADE
);