Write SQL code that creates or update a view named same_orders_vw, which will also create columns before it extract data from the database. The view must store details of customers who have ordered the same books as the one in order number 1007. The data to be stored in the view must contain customer no, customer names, book title, address and city as single and quantity. Sort the output in ascending order of customer no.
CREATE
ALGORITHM = UNDEFINED
DEFINER = `root`@`localhost`
SQL SECURITY DEFINER
VIEW `ecommerce`.`same_orders_vw` AS
SELECT
`ecommerce`.`products`.`name` AS `ProductName`,
`ecommerce`.`products`.`brand` AS `brand`,
`ecommerce`.`sales`.`sales_description` AS `sales_description`,
`ecommerce`.`sales`.`customer_feedback` AS `customer_feedback`
FROM
`ecommerce`.`products`
WHERE `ecommerce`.`products_id=107`;
Comments
Leave a comment