MySQL Query Optimisation - JOIN?

前端 未结 4 1688
清酒与你
清酒与你 2021-01-24 06:20

One for all you MySQL experts :-)

I have the following query:

SELECT o.*, p.name, p.amount, p.quantity 
FROM orders o, products p 
WHERE o.id = p.order_i         


        
4条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-24 06:39

    SELECT *:

    Selecting all columns with the * wildcard will cause the query's meaning and behavior to change if the table's schema changes, and might cause the query to retrieve too much data.

    The != operator is non-standard:

    Use the <> operator to test for inequality instead.

    Aliasing without the AS keyword: Explicitly using the AS keyword in column or table aliases, such as "tbl AS alias," is more readable than implicit aliases such as "tbl alias".

提交回复
热议问题