【发布时间】:2016-06-23 15:09:00
【问题描述】:
我正在 Laravel 中做一个项目,该项目是对旧版 Vanilla PHP 项目的更新,我遇到了一个在 Laravel 中无法完全复制的查询。
我需要一些帮助。这个想法只是简单地计算查询中提到的与用户提供的电子邮件匹配的任何表中的所有电子邮件。此外,根据各自的表格,电子邮件创建日期应大于或等于两天。
$sqlDuplicates = "
select count(*) as total from (
select distinct(email) from clientes where created_date>='".$data1."' and email = :txEmail
union all (
select distinct(txEmailC2L) from records_SegurosLogoC2L where dtCreated>='".$data1."' and txEmailC2L = :txEmail
)
union all (
select distinct(txEmailC2L) from records_SimuleSegurosLogoC2L where dtCreated>='".$data1."' and txEmailC2L = :txEmail
)
union all (
select distinct(email) from records_LogoOnline where created_date>='".$data1."' and email = :txEmail
)
union all (
select distinct(email) from records_SegurosAutoEconomico where created_date>='".$data1."' and email = :txEmail
)
union all (
select distinct(email) from records_SimuleSegurosLogo where created_date>='".$data1."' and email = :txEmail
)
) as data
";
这就是查询。如果有人能提供帮助,我将不胜感激
【问题讨论】:
-
laravel.com/docs/5.2/queries#unions 应该可以帮助您入门
标签: php mysql laravel eloquent