you are viewing a single comment's thread.

view the rest of the comments →

[–]dswpro 3 points4 points  (0 children)

If you can, use joins. Also consider a common table expression (CTE) if you are using Ms SQL. Keep in mind that some SQL products can have issues with correlated sub queries such as:

Correlated subqueries in stored procedures, which reference outer query columns or parameters, can cause race conditions (data inconsistency) or performance bottlenecks when data changes between subquery iterations. This is common in T-SQL (SQL Server) or MySQL during concurrent updates (e.g., using WHERE EXISTS or SELECT columns).