Reputation: 3015
Trying to pick up some Sql and am confused by the following example. Would anyone happen to know why:
SELECT Orders.OrderID, Customers.CustomerName, Orders.OrderDate, Customers.CustomerID
From Orders
Inner Join Customers
ON Orders.CustomerID=Customers.CustomerID
WHERE Orders.OrderDate LIKE '%6';
Happens to return over 100 entries with an Order Date ending in 1996, while on the other hand:
SELECT Orders.OrderID, Customers.CustomerName, Orders.OrderDate, Customers.CustomerID
From Orders
Inner Join Customers
ON Orders.CustomerID=Customers.CustomerID
WHERE Orders.OrderDate LIKE '%96';
returns me 0 entries. I'm using the customers data from w3schools. I'm quite confused why this wouldn't work.
Upvotes: 0
Views: 335
Reputation: 32713
I suspect OrderDate is a Date or DateTime field. Try this instead:
WHERE
YEAR(Orders.OrderDate) = 1996
Upvotes: 4