SELECT order_item_id FROM order_items WHERE product_id = 11
Find the ids of all the order items whose product id is 11.
CREATE TABLE `Customers` (
`customer_id` INTEGER PRIMARY KEY,
`customer_name` VARCHAR(80),
`customer_details` VARCHAR(255)
);
CREATE TABLE `Invoices` (
`invoice_number` INTEGER PRIMARY KEY,
`invoice_date` DATETIME,
`invoice_details` VARCHAR(255)
);
CREATE TABLE `Orders` (
`order_id` INTEGER PRIMARY KEY,
`customer_id` INTEGER NOT NULL,
`order_status` VARCHAR(10) NOT NULL,
`date_order_placed` DATETIME NOT NULL,
`order_details` VARCHAR(255),
FOREIGN KEY (`customer_id` ) REFERENCES `Customers`(`customer_id` )
);
CREATE TABLE `Products` (
`product_id` INTEGER PRIMARY KEY,
`product_name` VARCHAR(80),
`product_details` VARCHAR(255)
);
CREATE TABLE `Order_Items` (
`order_item_id` INTEGER PRIMARY KEY,
`product_id` INTEGER NOT NULL,
`order_id` INTEGER NOT NULL,
`order_item_status` VARCHAR(10) NOT NULL,
`order_item_details` VARCHAR(255),
FOREIGN KEY (`order_id` ) REFERENCES `Orders`(`order_id` ),
FOREIGN KEY (`product_id` ) REFERENCES `Products`(`product_id` )
);
CREATE TABLE `Shipments` (
`shipment_id` INTEGER PRIMARY KEY,
`order_id` INTEGER NOT NULL,
`invoice_number` INTEGER NOT NULL,
`shipment_tracking_number` VARCHAR(80),
`shipment_date` DATETIME,
`other_shipment_details` VARCHAR(255),
FOREIGN KEY (`order_id` ) REFERENCES `Orders`(`order_id` ),
FOREIGN KEY (`invoice_number` ) REFERENCES `Invoices`(`invoice_number` )
);
CREATE TABLE `Shipment_Items` (
`shipment_id` INTEGER NOT NULL,
`order_item_id` INTEGER NOT NULL,
FOREIGN KEY (`order_item_id` ) REFERENCES `Order_Items`(`order_item_id` ),
FOREIGN KEY (`shipment_id` ) REFERENCES `Shipments`(`shipment_id` )
);
INSERT INTO Customers (`customer_id`, `customer_name`, `customer_details`) VALUES (1, 'Savannah', 'rerum');
INSERT INTO Invoices (`invoice_number`, `invoice_date`, `invoice_details`) VALUES (1, '1989-09-03 16:03:05', 'vitae');
INSERT INTO Orders (`order_id`, `customer_id`, `order_status`, `date_order_placed`, `order_details`) VALUES (1, 2, 'Shipped', '2009-02-21 15:26:19', NULL);
INSERT INTO Products (`product_id`, `product_name`, `product_details`) VALUES (1, 'food', NULL);
INSERT INTO Shipments (`shipment_id`, `order_id`, `invoice_number`, `shipment_tracking_number`, `shipment_date`, `other_shipment_details`) VALUES (1, 5, 13, '3452', '1983-08-13 22:34:11', NULL);
INSERT INTO Order_Items (`order_item_id`, `product_id`, `order_id`, `order_item_status`, `order_item_details`) VALUES (1, 4, 6, 'Finish', NULL);
INSERT INTO Shipment_Items (`shipment_id`, `order_item_id`) VALUES (11, 12);