J
j_gold
Hi,
The following query gives me a Run-time error '3146' ODBC call failed. I've
tested each select statement individually, and the queires work.
If I run two of the queries together e.g. 1st and 2nd select statements or 1
and 3 or 2 and 3, as unions, each of those work. However, when I try and run
the whole lot, it blows up.
What am I doing wrong
, thanks.
'Select all Persons who are Faculty & Researchers
sqlQuery = "SELECT *, 'faculty' as [personType], 'y' as [Researcher] "
sqlQuery = sqlQuery & "FROM Person P "
sqlQuery = sqlQuery & "WHERE P.personID IN (SELECT F.personID FROM Faculty
F) "
sqlQuery = sqlQuery & "AND P.personID IN (SELECT R.personID FROM Researcher
R) "
'Select all Persons who are Faculty & NOT Researchers
sqlQuery = sqlQuery & "UNION "
sqlQuery = sqlQuery & "SELECT *, 'faculty' as [personType], 'n' as
[Researcher] "
sqlQuery = sqlQuery & "FROM Person P "
sqlQuery = sqlQuery & "WHERE P.personID "
sqlQuery = sqlQuery & "IN (SELECT F.personID FROM Faculty F) "
sqlQuery = sqlQuery & "AND P.personID NOT IN (SELECT R.personID FROM
Researcher R) "
'Select all Persons who are Grads and Researchers
sqlQuery = sqlQuery & "UNION "
sqlQuery = sqlQuery & "SELECT *, 'grad' as [personType], 'y' as [Researcher] "
sqlQuery = sqlQuery & "FROM Person P "
sqlQuery = sqlQuery & "WHERE P.personID "
sqlQuery = sqlQuery & "IN (SELECT G.personID FROM GradStudent G) "
sqlQuery = sqlQuery & "AND P.personID IN (SELECT R.personID FROM Researcher
R) ;"
The following query gives me a Run-time error '3146' ODBC call failed. I've
tested each select statement individually, and the queires work.
If I run two of the queries together e.g. 1st and 2nd select statements or 1
and 3 or 2 and 3, as unions, each of those work. However, when I try and run
the whole lot, it blows up.
What am I doing wrong
![Smile :-) :-)](/styles/default/custom/smilies/smile.gif)
'Select all Persons who are Faculty & Researchers
sqlQuery = "SELECT *, 'faculty' as [personType], 'y' as [Researcher] "
sqlQuery = sqlQuery & "FROM Person P "
sqlQuery = sqlQuery & "WHERE P.personID IN (SELECT F.personID FROM Faculty
F) "
sqlQuery = sqlQuery & "AND P.personID IN (SELECT R.personID FROM Researcher
R) "
'Select all Persons who are Faculty & NOT Researchers
sqlQuery = sqlQuery & "UNION "
sqlQuery = sqlQuery & "SELECT *, 'faculty' as [personType], 'n' as
[Researcher] "
sqlQuery = sqlQuery & "FROM Person P "
sqlQuery = sqlQuery & "WHERE P.personID "
sqlQuery = sqlQuery & "IN (SELECT F.personID FROM Faculty F) "
sqlQuery = sqlQuery & "AND P.personID NOT IN (SELECT R.personID FROM
Researcher R) "
'Select all Persons who are Grads and Researchers
sqlQuery = sqlQuery & "UNION "
sqlQuery = sqlQuery & "SELECT *, 'grad' as [personType], 'y' as [Researcher] "
sqlQuery = sqlQuery & "FROM Person P "
sqlQuery = sqlQuery & "WHERE P.personID "
sqlQuery = sqlQuery & "IN (SELECT G.personID FROM GradStudent G) "
sqlQuery = sqlQuery & "AND P.personID IN (SELECT R.personID FROM Researcher
R) ;"