Sunday, February 12, 2012

alternative way

SELECT *
FROM organization
WHERE (departmentID = divisionID) AND (divisionID = branchID) AND
(branchID = sectionID) AND (sectionID = unitID)

Is there anyway I can make this query more simlified w/o repeating the
same column in the where clause?

thanks
s/RC> SELECT *
> FROM organization
> WHERE (departmentID = divisionID) AND (divisionID = branchID) AND
> (branchID = sectionID) AND (sectionID = unitID)
> Is there anyway I can make this query more simlified w/o repeating the
> same column in the where clause?

SELECT *
FROM organization
WHERE departmentID = all (
select divisionID union
select branchID union
select sectionID union
select unitID
)

Craig|||"Craig Kelly" <cnkelly.nospam@.nospam.net> wrote in message
news:zsldc.35902$vo5.1148556@.bgtnsc05-news.ops.worldnet.att.net...
> > SELECT *
> > FROM organization
> > WHERE (departmentID = divisionID) AND (divisionID = branchID) AND
> > (branchID = sectionID) AND (sectionID = unitID)
> > Is there anyway I can make this query more simlified w/o repeating the
> > same column in the where clause?
> SELECT *
> FROM organization
> WHERE departmentID = all (
> select divisionID union
> select branchID union
> select sectionID union
> select unitID
> )

Keep in mind there's a very good chance the optimizer may rewrite the query
in any case.

> Craig|||I wonder it executes faster than the original query stmt?
thanks again,
s/RC

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

No comments:

Post a Comment