Wednesday, February 24, 2010

Programmer - Why use JOIN rather than inner queries

Programmer Question

I find myself unwilling to push to using JOIN when I can easily solve the same problem by using an inner query:



e.g.



SELECT COLUMN1, ( SELECT COLUMN1 FROM TABLE2 WHERE TABLE2.ID = TABLE1.TABLE2ID ) AS COLUMN2 FROM TABLE1;



My question is, is this a bad programming practice? I find it easier to read and maintain as opposed to a join.



UPDATE



I want to add that there's some great feedback in here which in essence is pushing be back to using JOIN. I am finding myself less and less involved with using TSQL directly these days as of a result of ORM solutions (LINQ to SQL, NHibernate, etc.), but when I do it's things like correlated subqueries which I find are easier to type out linearly.

No comments:

Post a Comment

LinkWithin

Related Posts with Thumbnails