输入banner图图片脚本导航/分类

MySQL:子查询

IN(

        SELECT cust_id

        FROM orders

        WHERE order_num IN(

                  SELECT order_num 

                  FROM orderitems

                  WHERE prod_id=‘TNT2‘ 

                  )        

        )

2、计算字段中

例2:查询每个客户的订单总数

SELECT cust_id,cust_name,cust_contact,

    (SELECT COUNT(*)

    FROM orders

    WHERE orders.cust_id=customers.cust_id)

FROM customers ORDER BY cust_name

MySQL:子查询

标签:bsp   www   语句   col   参考   tac   购物   信息   custom