MySQL过滤记录添加特定日期

时间:2014-01-14 19:21:42

标签: php mysql sql

我想过滤记录以添加日期。这段代码有错误,我知道但是如何过滤记录呢?

select * from `UserAdTypes`
inner join `Ads` on `Ads.id` = `UserAdTypes`.`ad_id`
inner join `AdEducationPrices` on `AdEducationPrices`.`ad_id` = `Ads`.`id`
inner join `UserAds` on `UserAds`.`ad_id` = `Ads.id`
inner join `AdTimes` on `AdTimes`.`id` = `UserAdTypes`.`times_type`
left join `AdMedias` on `AdMedias`.`ad_id` = `Ads`.`id`
where `Ads`.`is_publish` = 1 and `UserAds`.`is_purchased` = 1 and 
      `UserAdTypes`.`is_purchased` = 1 and `UserAdTypes`.`adtype_id` = 3 
and DATE_ADD( STR_TO_DATE( `UserAdTypes`.`started_at`,  '%d/%m/%Y' ) , INTERVAL `UserAdTypes`.`times` `AdTimes`.`tag` ) >= CURDATE() )
and DATE_ADD( STR_TO_DATE( `UserAds`.`started_at`,  '%d/%m/%Y' ) , INTERVAL `UserAds`.`times` `AdTimes`.`tag` ) >= CURDATE() )
orderby Rand() limit 1

My Tables

0 个答案:

没有答案