Northiwind CustomerSELECT *
FROM Customer
WHERE ((Country = 'USA' AND (City = 'San Francisco' OR City = 'Portland')) OR Country = 'UK')这样怎么不能查出我想要的数据啊?
FROM Customer
WHERE ((Country = 'USA' AND (City = 'San Francisco' OR City = 'Portland')) OR Country = 'UK')这样怎么不能查出我想要的数据啊?
FROM Customers
WHERE ((Country = 'USA' AND (City = 'San Francisco' OR City = 'Portland')) OR Country = 'UK')
FROM Customers
WHERE (
(Country = 'USA' AND (City = 'San Francisco' OR City = 'Portland')
) OR Country = 'UK')
--result(10 row(s) affected)
WHERE ((Country = 'USA' AND (City = 'San Francisco' OR City = 'Portland')) OR Country = 'UK')相当于
SELECT * FROM Customer
where (Country = 'USA' AND City = 'San Francisco') or
(Country = 'USA' AND City = 'Portland') or
Country = 'UK'
then City = 'San Francisco' OR City = 'Portland'
or
if Country = 'UK'
我怀疑是第一个OR惹的祸。不知道这种SQL的解析机制是怎样的?