Re: Finding missing ID

2002-10-12 Thread Peter Brawley

Chuck,

 I have database that has grown in size, I want to see what ID files have
 been deleted. Is there a way or do I have to print out the list and find
 them myself?

Assuming by files you mean rows, and assuming a table named t1, a column
in it named id, and you having done something like ...

SELECT @idmax := MAX( id ) FROM t1;

then this gives you missing numbers:

SELECT t1.id
FROM t1 LEFT JOIN t1 AS t2
ON t1.id = t2.id-1
WHERE t2.id IS NULL AND t1.id  @idmax;

Once MySQL gives us subqueries in 4.1 (December?), it'll be easier ...

SELECT id AS id1 from t1
WHERE id  idmax AND
NOT EXISTS (SELECT id FROM t1 WHERE id = id1 - 1);

HTH

PB




-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Finding missing ID

2002-10-12 Thread Chuck \PUP\ Payne

Hi,

I have database that has grown in size, I want to see what ID files have
been deleted. Is there a way or do I have to print out the list and find
them myself?

Is there a sql or query statement that will let me find them.

Chuck Payne


-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php