I am not sure why this behaves this way. I need to select few values from two tables based on some criteria which should be clear from the query i tried below.
query = @"SELECT n.borrower, a.sum, n.lender FROM Notification AS n, Acknowledgment AS a
WHERE n.deleted=@del2 AND n.id IN (SELECT parent_id FROM Acknowledgment
WHERE status=@status AND deleted=@del1)";
This returns more rows (12) than expected.
I have two tables Notification and Acknowledgment both which have field "sum". When I try the query below it gives the correct 3 rows as expected.
@"SELECT n.borrower, n.sum, n.lender FROM Notification AS n
WHERE n.deleted=@del2 AND n.id IN (SELECT parent_id FROM Acknowledgment
WHERE status=@status AND deleted=@del1)";
Now I need to extend this query so that I need a.sum
and not n.sum
. But when I try the first query, it gives a lot more rows, I mean the WHERE
condition doesn't work. I dunno if its a quirk with MS Access or something wrong with query. I appreciate an alternate implementation in access if my query seems fine 'cos it simply doesn't work! :)
I have read here that different databases implement select in different ways. Dunno if its something specific with access..
After suggestion from Li0liQ, I tried this:
@"SELECT n.borrower, a.sum, n.lender FROM Notification AS n
INNER JOIN Acknowledgment AS a ON a.parent_id = n.id AND a.status=@status AND a.deleted=@deleted1
WHERE n.deleted=@deleted2"
But I now get a "JOIN expression not supported" error.