Simplified example:
select ticket_id, `number` as 'ticket number', (SELECT count(*) from ost_thread_entry join ost_thread on ost_thread_entry.thread_id = ost_thread.id where ost_thread.object_id = 1234) as 'number of posts in ticket' from ost_ticket
I need to quote the value in ticket_id
, not 1234
You can use tables here Aliases :
Note that you can also write the query without using correlated subqueries and instead use joins: