How NOT to Code - Challenge 11
Today's challenge is in SQL. So what's wrong with this SQL statement? We'll assume it's running on SQL Server, but I suspect this is bad across most if not all database engines
SELECT Persons.LastName, Persons.FirstName, Orders.OrderNo
FROM Persons INNER JOIN Orders ON Persons.P_Id=Orders.P_Id
WHERE Persons.PhoneNumber like '404%' or Orders.Processed = 1
ORDER BY Persons.LastName
Dale Fraser wrote on 02/09/109:24 AM
Well you dont really tell us what the query is supposed to be doing.But assuming you want a lost of all people where they have a a 404 phone numer or a processed order it looks fine.
However it doesnt make much sense that you would want such a list.