Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 2 of 2 total
Thread edb count function problem
Wed, May 14 2014 5:52 AMPermanent Link

codealfa

We use Delphi 7 and edb 2.16b2.
We found a problem when using count function.
I attached the sample database for analizing the problem.

/* BAD:   result: 3 */
SELECT COUNT(*)
FROM t1
WHERE EXISTS(SELECT * FROM t2 WHERE t2.t1id = t1.id);

/* GOOD:   result: 2 */
SELECT COUNT(id)
FROM t1
WHERE EXISTS(SELECT * FROM t2 WHERE t2.t1id = t1.id);

/* GOOD:   result: 2 rows */
SELECT *
FROM t1
WHERE EXISTS(SELECT * FROM t2 WHERE t2.t1id = t1.id);



Attachments: count_error.zip
Wed, May 14 2014 7:29 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

codealfa


It does look like a bug,  You should report it to ElevateSoft support to bring it to Tim's attention quicker.

In the meantime I'd suggest using an alternative like

SELECT COUNT(*)
FROM t1
WHERE id in (SELECT t1id FROM t2)

Roy Lambert
Image