sql Listados de clientesconinformaciónsobrelaprofocióndebolsitashigiénicasdepor vida:

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sql Listados de clientesconinformaciónsobrelaprofocióndebolsitashigiénicasdepor vida:相关的知识,希望对你有一定的参考价值。

SELECT
    c.customers_id, c.customers_email_address
FROM
    customers c
        INNER JOIN
    orders o ON o.customers_id = c.customers_id
        INNER JOIN
    discount_coupons_to_orders dc2o ON dc2o.orders_id = o.orders_id
WHERE
    coupons_id IN (SELECT
            CONCAT(dc.coupons_id, '_DISABLED')
        FROM
            discount_coupons dc
                INNER JOIN
            discount_coupons_automatic_gifts ag ON dc.coupons_id = ag.coupons_id
        WHERE
            CONVERT( ag.product_id , UNSIGNED) = 8912
                AND dc.coupons_discount_type = 'gift-automatic'
                AND (ag.date_end IS NULL
                OR ag.date_end >= NOW()))
GROUP BY c.customers_id
SELECT
  c.customers_id, 
  c.customers_email_address
FROM
  customers c
  JOIN orders o ON o.customers_id = c.customers_id
  JOIN discount_coupons_to_orders dc2o ON dc2o.orders_id = o.orders_id
  JOIN discount_coupons dc ON dc.coupons_id = dc2o.coupons_id
  JOIN discount_coupons_automatic_gifts ag ON dc.coupons_id = ag.coupons_id
WHERE
  CONVERT(ag.product_id, UNSIGNED) = 8912 
  AND dc.coupons_discount_type = 'gift-automatic' 
  AND (ag.date_end IS NULL OR ag.date_end >= NOW()) -- mysql tiene una horas menos que php
GROUP BY
  c.customers_id

以上是关于sql Listados de clientesconinformaciónsobrelaprofocióndebolsitashigiénicasdepor vida:的主要内容,如果未能解决你的问题,请参考以下文章

sql SQL Anywhere:Mostrar Tablas y Campos de la Base de Datos

sql SQL脚本para listar todas las tablas de una base de datos

sql Borrado de documentos de la papelera

sql Adecuaciónparacalculo de indicadores de totales de alumnosenpágina校长

sql Tabla Empresa Taller de Base de Datos

sql [SQL] Reduzir Log de Transacoes