简化示例:
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
我需要引用 ticket_id
中的值,而不是 1234
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
您可以在此处使用表别名:
请注意,您也可以在不使用相关子查询的情况下编写查询,而是使用联接: