1. 程式人生 > >根據條件查詢不同的表

根據條件查詢不同的表

SELECT 
            u.user_name As "fyUser.userName",
            a.id AS "id",
            a.del_flag AS "delFlag",
            a.istatus AS "istatus",
            a.user_id AS "fyuser.id",
            a.order_no AS "orderNo",
            a.order_id AS "orderId",
            a.product_id AS "productId",
            a.pruduct_itype AS "pruductItype",
            a.count AS "count",
            (CASE  #{itype} WHEN '1'  THEN
                (select ap.name from activity_product ap where ap.id = a.product_id) 
            ELSE
                (select ap.name from normal_product ap where ap.id = a.product_id)
            END) AS "name",
            a.price AS "price"
        FROM normal_product_order_detail a