edit: the error message is »Unknown column 'date1' in 'where clause'«
the reason for this is, that the op aliases the if statement to the alias-name 'e.date1'. in his where clause he writes e.date1 without any backticks. e.date1 will look for a column date1 in table e, and is different from the alias 'e.date1' (with backticks)
you are aliasing the subquery to the name "e.date1"
and then reference the column "date1"
in the table "e"
—which does not exist.
you have to either alias to "date1"
and then use WHERE date1
or write the where as WHERE ``e.date1``
(fucked up by markdown …)
full code:
SELECT
IF( e.weekly,
DATE_ADD(DATE(e.time),
INTERVAL CEIL(DATEDIFF('2010-04-08', e.time)/7) WEEK ),
DATE(e.time)) AS `e.date1`,
`v`.`lat`,
`v`.`lng`
FROM `events` AS `e`
INNER JOIN `venues` AS `v` ON e.venue_id = v.id
WHERE `e.date1` > '2010-09-01'
or
SELECT
IF( e.weekly,
DATE_ADD(DATE(e.time),
INTERVAL CEIL(DATEDIFF('2010-04-08', e.time)/7) WEEK ),
DATE(e.time)) AS e.date1,
`v`.`lat`,
`v`.`lng`
FROM `events` AS `e`
INNER JOIN `venues` AS `v` ON e.venue_id = v.id
WHERE e.date1 > '2010-09-01'