Question : Deleting from multiple tables

Got the tables defined below. How can I remove all records that correspond to
a particular part number? Can I do it with one query or must I do it with
multiple queries?

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
CREATE TABLE `niins` (
	`NIINS_ID` INT(10) NOT NULL AUTO_INCREMENT, ------+
	`PARTNO` VARCHAR(250) NOT NULL DEFAULT '',        |
	`DESCRIPTION` VARCHAR(255) NOT NULL,              |
	`NSN` VARCHAR(255) NOT NULL,                      |
	INDEX `Index 1` (`NIINS_ID`)                      |
)                                                         |
                                                          | 
CREATE TABLE `niin` (                                     |
	`NIINS_ID` INT(10) NOT NULL DEFAULT '0',    ------+
	`NIIN_ID` INT(10) NOT NULL AUTO_INCREMENT,  ------+---+---+
	`NSN_NUMBER` VARCHAR(255) NOT NULL DEFAULT '0',   |   |   |
        <SNIP OTHER FIELDS>                               |   |   |
	INDEX `Index 1` (`NIIN_ID`)                       |   |   |
)                                                         |   |   |
                                                          |   |   |
CREATE TABLE `niinid` (                                   |   |   |
	`NIINID_ID` INT(10) NOT NULL AUTO_INCREMENT,      |   |   |
	`NIIN_ID` INT(10) NOT NULL DEFAULT '0', ----------+   |   |
	`FIIG` VARCHAR(20) NOT NULL DEFAULT '0',              |   |
        <SNIP OTHER FIELDS>                                   |   |
	INDEX `Index 1` (`NIINID_ID`),                        |   |
	INDEX `Index 2` (`NIIN_ID`)                           |   |
)                                                             |   |
                                                              |   |
CREATE TABLE `niinxref` (                                     |   |
	`NIINXREF_ID` INT(10) NOT NULL AUTO_INCREMENT,        |   |
	`NIIN_ID` INT(10) NOT NULL DEFAULT '0', --------------+   |
        <SNIP OTHER FIELDS>                                       |
	INDEX `Index 1` (`NIINXREF_ID`),                          |
	INDEX `Index 2` (`NIIN_ID`)                               |
)                                                                 |
                                                                  |
CREATE TABLE `niinprocurement` (                                  |
	`NIINPROCUREMENT_ID` INT(10) NOT NULL AUTO_INCREMENT,     |
	`NIIN_ID` INT(10) NOT NULL DEFAULT '0', ------------------+
        <SNIP OTHER FIELDS>
	INDEX `Index 1` (`NIINPROCUREMENT_ID`),
	INDEX `Index 2` (`NIIN_ID`)
)

Answer : Deleting from multiple tables

in MySQL, you can indeed delete from several tables at once:
http://dev.mysql.com/doc/refman/4.1/en/delete.html

1:
2:
3:
4:
5:
6:
multiple-table syntax:

DELETE [LOW_PRIORITY] [QUICK] [IGNORE]
    tbl_name[.*] [, tbl_name[.*]] ...
    FROM table_references
    [WHERE where_condition]
Random Solutions  
 
programming4us programming4us