当前查询
SELECT vcc.name AS item, vcc.prodid, vcc.quantity AS qty,
UPPER(vcc.custom_message) AS nickname, vfd1.value AS fullname,
vfd2.value as email, vcc.purchaseid, vcc.price
FROM vxu_4_wpsc_cart_contents AS vcc INNER JOIN
vxu_4_wpsc_submited_form_data AS vfd1
ON vcc.purchaseid = vfd1.log_id AND vfd1.form_id = 2 INNER JOIN
vxu_4_wpsc_submited_form_data AS vfd2
ON vcc.purchaseid = vfd2.log_id AND vfd2.form_id = 9
我想要添加条件'处理过的条件'在表格' vxu_4_wpsc_purchase_logs是' 2',因此只返回已完成的销售。我正在努力学习逻辑/语法。希望图像可读。
答案 0 :(得分:0)
试试这个。我已按id
加入了表purchase_logs,并按列processed
过滤了结果集,其值等于2
SELECT vcc.name AS item,
vcc.prodid,
vcc.quantity AS qty,
UPPER(vcc.custom_message) AS nickname,
vfd1.value AS fullname,
vfd2.value as email,
vcc.purchaseid,
vcc.price
FROM vxu_4_wpsc_cart_contents AS vcc
INNER JOIN vxu_4_wpsc_submited_form_data AS vfd1 ON vcc.purchaseid = vfd1.log_id
AND vfd1.form_id = 2
INNER JOIN vxu_4_wpsc_submited_form_data AS vfd2 ON vcc.purchaseid = vfd2.log_id
AND vfd2.form_id = 9
INNER JOIN vxu_4_wpsc_purchase_logs AS wpl ON wpl.id = vcc.purchaseid
WHERE wpl.processed = 2