MySQL ResultSet - count rows? - JDBC JAVA

This is a discussion on MySQL ResultSet - count rows? - JDBC JAVA ; Arne Vajhøj wrote: > Lew wrote: >> Dyreatnews@sun.com wrote: >>> Ruud is making a very good point. I've just been told that the the >>> SELECT COUNT(*) approach will only be guaranteed to work if you execute >>> both SELECTs ...

+ Reply to Thread
Page 3 of 3 FirstFirst 1 2 3
Results 21 to 23 of 23

MySQL ResultSet - count rows?

  1. Default Re: MySQL ResultSet - count rows?

    Arne Vajhøj wrote:
    > Lew wrote:
    >> Dyreatnews@sun.com wrote:
    >>> Ruud is making a very good point. I've just been told that the the
    >>> SELECT COUNT(*) approach will only be guaranteed to work if you execute
    >>> both SELECTs in a single transaction AND use SERIALIZABLE isolation
    >>> level. Even at REPEATABLE READ you may see new rows added since the
    >>> previous select, (but all rows counted will have the same value
    >>> throughout the transaction).

    >>
    >> You won't "see" those new rows added until after the transaction
    >> completes.

    >
    > You will.
    >
    > user 1 - SELECT COUNT(*)
    > user 2 - INSERT
    > user 1 - SELECT
    >
    > Only SERIALIZABLE will prevent this.


    I stand corrected. Thanks, Dyreatnews and Arne.

    --
    Lew

  2. Default Re: MySQL ResultSet - count rows?

    Use this syntax, if you use MySql >= Version 5.1:

    SELECT COUNT(*) FROM (your_query) AS xy;

    This sql will give you exactly the number of rows which your_query delievers.
    My example SQL is like this:
    select count(*) from
    (select count(*)
    from student_statistik
    where dati like '2009-06-17%'
    group by sessionid)
    as foo;
    You need an alias name 'foo', for every derived table must have its own alias.
    I hope this would help ^.^

  3. Default Re: MySQL ResultSet - count rows?

    hi...

    [url 'http://www.google.com']Click Here to Know More[/url]

+ Reply to Thread
Page 3 of 3 FirstFirst 1 2 3

Similar Threads

  1. [MS SQL 2005] How can I get estimated rows count?
    By Application Development in forum JDBC JAVA
    Replies: 1
    Last Post: 08-11-2007, 04:58 PM
  2. Re: how to count exactly the rows of a ResulSet
    By Application Development in forum Java
    Replies: 1
    Last Post: 06-30-2007, 01:46 PM
  3. Re: how to count exactly the rows of a ResulSet
    By Application Development in forum Java
    Replies: 1
    Last Post: 06-29-2007, 03:57 PM
  4. JDBC: Fast way to find the number of rows in a ResultSet?
    By Application Development in forum JDBC JAVA
    Replies: 7
    Last Post: 05-26-2007, 12:15 PM
  5. JDBC/ MySQL : memory release after ResultSet.getString()
    By Application Development in forum JDBC JAVA
    Replies: 2
    Last Post: 05-11-2005, 02:15 AM