Is there an inline sql command that is similar to or produces the same results as intersect? If not is there a way to rewrite the query so it is in one query rather than using intersect?
My current sql query is:
SELECT
c.Log_Link
FROM
Classes c INNER JOIN
ClassValues cv ON c.Class_Link = cv.Class_Link INNER JOIN
ClassSelection cs ON cv.ClassSelection_Link = cs.ClassSelection_Link
WHERE
cs.classselection_link IN (95,1)
But what I'm really after is:
SELECT
c.Log_Link
FROM
Classes c INNER JOIN
ClassValues cv ON c.Class_Link = cv.Class_Link INNER JOIN
ClassSelection cs ON cv.ClassSelection_Link = cs.ClassSelection_Link
WHERE
cs.classselection_link = 95
INTERSECT
SELECT
c.Log_Link
FROM
Classes c INNER JOIN
ClassValues cv ON c.Class_Link = cv.Class_Link INNER JOIN
ClassSelection cs ON cv.ClassSelection_Link = cs.ClassSelection_Link
WHERE
cs.classselection_link = 1
Thanks
cs.classselection_linkcannot be equal to 1 and 95 which is what, in effect, you are asking for in the second query.INTERSECT? It exists for a reason, and that is cases like yours. There are other ways to write the query, but they will be a lot less clear than just usingINTERSECTlike you did in your example. Is there a reason you want to obfuscate the code?INTERSECTclauses?INTERSECTdoes not mean you have 2 queries. You still have 1 query (with 2 subqueries).