I try to avoid subqueries, if possible. In some cases, you can do the
fine tuning right in the join statement (something a lot of people
aren't aware of).
SELECT a.ColumnOne, a.ColumnTwo, b.ColumnOne
FROM TableA a
INNER JOIN TableB b ON a.pkid = b.fkid AND b.ColumnTwo = 'someString'
WHERE a.ColumnThree = 'someOtherString'
Note the additional criteria added to the end of the INNER JOIN
statement. This will filter down the records being pulled from TableB
before the join is applied.
-Carl V.
On 12/7/2013 4:17 PM, George Gallen wrote:
> Depending on what you need, a combination of sub queries and joins might the
> best solution. Use a series of sub queries to select and fine tune the
> primary keys of the main table with a final query that consists of the join
> to display the data. This way your not linking everything together first and
> then doing a where to fine tune,
>
> George
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: http://www.houseoffusion.com/groups/sql/message.cfm/messageid:3522
Subscription: http://www.houseoffusion.com/groups/sql/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/sql/unsubscribe.cfm