My question is very similar to this one How to reference a custom field in SQL I have the following query:
SELECT * , (SELECT COUNT( id )
FROM cms_store_items
WHERE speaker = cms_store_items_speakers.id
) AS count
FROM cms_store_items_speakers
LIMIT 0 , 30
I need to add a WHERE clause that looks like WHERE count > 0
but when I do I get the error Unknown column 'count' in 'where clause'
is there anyway for me to reference the custom field in my where clause without duplicating logic?
I could just place the logic for the where clause in my code but I don't want to send what may well be more then 1000 rows to the app if not needed, it just seems like a waste of resources.