Re: Second opinion for a query
From: Hugo Kornelis (hugo_at_pe_NO_rFact.in_SPAM_fo)
Date: 09/19/04
- Next message: Karl Prosser: "Re: DYNAMIC SQL TECHNIQUE"
- Previous message: Hugo Kornelis: "Re: List of bad practices"
- In reply to: Steve Lewis - Website Nation: "Second opinion for a query"
- Next in thread: Steve Lewis - Website Nation: "Re: Second opinion for a query"
- Reply: Steve Lewis - Website Nation: "Re: Second opinion for a query"
- Messages sorted by: [ date ] [ thread ]
Date: Sun, 19 Sep 2004 23:50:20 +0200
On Sun, 19 Sep 2004 02:08:56 -0400, Steve Lewis - Website Nation wrote:
>I wanted to get a second opinion on this:
Hi Steve,
An alternative for your query would be:
SELECT dbo.tblMembers.MemberID, dbo.tblMembers.FirstName,
dbo.tblImage.Image, dbo.tblImage.ImageOriginalFilename,
dbo.tblImage.Approved, dbo.tblImage.ImageDisplay
FROM dbo.tblMembers
LEFT OUTER JOIN dbo.tblImage
ON dbo.tblMembers.MemberID = dbo.tblImage.MemberID
AND dbo.tblImage.ImageDisplay = 'Thumbnail'
AND dbo.tblImage.Approved = 'Yes'
>BUT, it there a better way to do this?
You should judge by yourself if you think it's better. Run both against
your database and compare execution plans. Check if you understand the
logic and if you think you'll still understand it when you'll have to get
back to this query in a year or so from now.
>I read that Outer Joins are not
>all that good and that using NULL is not to great either. I looked into
>subqueries, but that seemed inappropriate.
Where did you read about outer joins being bad? I've never heard of this
before.
There are a lot of people claiming that NULLs should be avoided, but I've
yet to see a practical solution for many problems that are now easily
solved using NULLS. And the main argument against NULLS is that some
programmers don't understand how to handle them and mess things up as a
result - true, of course, but doesn't that call for better education
instead of moving to abolish NULLS?
Best, Hugo
-- (Remove _NO_ and _SPAM_ to get my e-mail address)
- Next message: Karl Prosser: "Re: DYNAMIC SQL TECHNIQUE"
- Previous message: Hugo Kornelis: "Re: List of bad practices"
- In reply to: Steve Lewis - Website Nation: "Second opinion for a query"
- Next in thread: Steve Lewis - Website Nation: "Re: Second opinion for a query"
- Reply: Steve Lewis - Website Nation: "Re: Second opinion for a query"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|