So I’m trying to find in my db two IDs with the same value at specific column i.e.
SELECT SALARY FROM TABLE1 WHERE ID='1'
INTERSECT
SELECT SALARY FROM TABLE2 WHERE ID='5'
So I did in VS2010
Dim ConnectionString As String
ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=C:\\;Extended Properties=dBase IV"
Dim dBaseConnection As New System.Data.OleDb.OleDbConnection(ConnectionString)
dBaseConnection.Open()
Dim myQ As String = "SELECT 'SALARY' FROM TABLE1 WHERE ID='1' INTERSECT SELECT 'SALARY' FROM TABLE2 WHERE ID='5'"
Dim dBaseCommand As New System.Data.OleDb.OleDbCommand(myQ, dBaseConnection)
Dim dBaseDataReader As System.Data.OleDb.OleDbDataReader = dBaseCommand.ExecuteReader(CommandBehavior.SequentialAccess)
And I get this error when the last line is executed
An unhandled exception of type ‘System.Data.OleDb.OleDbException’ occurred in System.Data.dll
Additional information: IErrorInfo.GetDescription failed with E_FAIL(0x80004005).
Impossible to believe, when I use UNION instead of INTERSECT works
Any ideas, thx
I am not exactly answering your question to resolve your error, but anyway this may be a workaround for what you are trying to do.
Instead of using intersect, you can use this query: