When To Use =?UTF-8?B?4oCcSGF2aW5n4oCd?= Clauses
From
Lawrence =?iso-8859-13?q?D=FFOliveiro?=@ldo@nz.invalid to
comp.databases.mysql on Thu Nov 26 23:41:04 2026
From Newsgroup: comp.databases.mysql
Trying to list block_recip entries in order in which they were last
used, including the number of times each one was used, omitting ones
which were never used:
select block_recip.email as email, from_unixtime(max(block_recip_hits.timestamp)) as last, count(*) from block_recip left join block_recip_hits on block_recip.email = block_recip_hits.email where block_recip.enabled = "1" and last is not null group by block_recip.email order by max(block_recip_hits.timestamp);
I get:
ERROR 1054 (42S22): Unknown column 'last' in 'WHERE'
So the “last” column can’t be referenced in a “where”-clause because it doesnt’ actually exist until after the “group by” takes effect.
But this works:
select block_recip.email as email, from_unixtime(max(block_recip_hits.timestamp)) as last, count(*) from block_recip left join block_recip_hits on block_recip.email = block_recip_hits.email where block_recip.enabled = "1" group by block_recip.email having last is not null order by max(block_recip_hits.timestamp);
--- Synchronet 3.21e-Linux NewsLink 1.2