|
-
Oct 9th, 2024, 06:02 AM
#2
Re: Help Optimize MySql Query
You can combine both queries in one so called correlated query like this
"SELECT *, (SELECT COUNT(DISTINCT(id_registro)) as QTDE FROM table2 WHERE id_planoconta=table1.id) AS CountOfRegistro FROM table1 ORDER BY num ASC"
The green part is what used to be your first query, the red part is the correlated second query.
cheers,
</wqw>
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|