September 7, 2013 at 6:24 am
in Which Sensory we use CTE
September 7, 2013 at 6:51 am
You might want to start by reading this:
http://www.4guysfromrolla.com/webtech/071906-1.shtml
and then if you have specific questions ask those questions in a new posting.
September 7, 2013 at 7:14 pm
coolrana.kumar69 (9/7/2013)
in Which Sensory we use CTE
I use CTEs now routinely instead of using sub-queries. Just a new way of doing it that seems more clear and structured to me.
So, instead of:
SELECT
r.Val
FROM
someTable AS r
WHERE
r.Val IN
(SELECT foo FROM someOtherTable)
Using CTE:
WITH
cteTest (foo)
AS (
SELECT foo FROM someOtherTable
),
cteResult (val)
AS (
SELECT
r.val
,t.foo
FROM someTable AS r
INNER JOIN cteTest AS t
ON r.val = t.foo
)
SELECT * FROM cteResult
CTEs can also be written to do recursive queries and that is a more complex subject.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply