11. Advanced SQL
Activity 11.01: Implementing the LIKE Operator
Solution:
- Enter the following query:
SELECT O.OrderID, O.CustomerID, O.OrderNumber, O.OrderDate, O.ShipmentDate, O.OrderStatus, O.Notes FROM Orders O WHERE O.Notes LIKE '%CUST%' AND O.ShipmentDate > '01051995'
We have set two filter conditions. Only when both are satisfied will the product be displayed.
- On execution of the query, your result will look similar to the following:
Figure 11.22: Customer notes post May 5, 1995
Notice that there are only three orders that have an order date post May 1, 1995
and have CUST
as part of the Notes
section.
Activity 11.02: Using Transactions
Solution:
- Execute the following code to verify the existence of the specific
OrderItems
rows:USE PACKT_ONLINE_SHOP; SELECT OrderItemID, OrderID, ProductID, Quantity, UnitPrice, Discount, Notes FROM OrderItems WHERE OrderID = 5;
The output...