我怀疑了。假设我得到了这个:
Invoice (Cod, CodCustomer)
Customer (Cod,Name)
我想选择X发票的客户名称:
SELECT Customer.Name FROM Invoice,Customer WHERE Customer.Cod = CodCustomer AND Invoice.Cod = "X"
在优化过程中,如果我这样做是否有区别
Customer.Cod = CodCustomer
或
CodCustomer = Customer.Cod
谢谢:)
答案 0 :(得分:0)
我认为应该是
Invoice.CodCustomer = Customer.Cod
这个顺序并不重要,因为它只是一个比较而且它是真实的。
否则您可以使用INNER JOIN
查询
SELECT a.Name
FROM Customer a
INNER JOIN Invoice b
ON a.Cod = b.CodCustomer
AND b.Cod = 'X' --note single quotes, you used double wich are not correct
答案 1 :(得分:0)
没有。但是你可以在此之前做第二次。
SELECT Customer.Name FROM Invoice,Customer WHERE Invoice.Cod = "X" AND Customer.Cod = CodCustomer
如果没有Cod
作为' x'的发票,这可能会提高您的效果。少了。