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 ...
-
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
-
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 ^.^
-
Re: MySQL ResultSet - count rows?
hi...
[url 'http://www.google.com']Click Here to Know More[/url]
Similar Threads
-
By Application Development in forum JDBC JAVA
Replies: 1
Last Post: 08-11-2007, 04:58 PM
-
By Application Development in forum Java
Replies: 1
Last Post: 06-30-2007, 01:46 PM
-
By Application Development in forum Java
Replies: 1
Last Post: 06-29-2007, 03:57 PM
-
By Application Development in forum JDBC JAVA
Replies: 7
Last Post: 05-26-2007, 12:15 PM
-
By Application Development in forum JDBC JAVA
Replies: 2
Last Post: 05-11-2005, 02:15 AM