🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: bit.listserv.sqlinfo
Article #341

Count in SQL...

#341
From: Gavin Wong
Date: Tue, 05 Oct 1999 00:00
20 lines
1319 bytes
Dear all,
Could you please tell me how to get the number of records in my database by
using the COUNT sql statement?
Let's say i have a Table call Mytable, the table contains two columns which
are BSBNO and NAME. I would like to know how many BSBNO(of type int) records
have been stored  in my Mytable. So that i wrote the following statement in
my Java JDBC program:

ResultSet rs = stmt.executeQuery("SELECT COUNT(BSBNO) FROM Mytable");
      while (rs.next()) { what should i write here??}


Shall i set:
int n = ResultSet rs = stmt.executeQuery("SELECT COUNT(BSBNO) FROM
Mytable");  ?? can i?
i need to know what's the value of "n".
Please help..Thanks.

with regards,
gavin.
Technical Details
Message-ID: <uRhK3.4157$lE.22937@ozemail.com.au>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 11355a,92a65899ed85587c,start
X-Google-Attributes: gid11355a,public
From: "Gavin Wong" <gavinthwong@ozemail.com.au>
Subject: Count in SQL...
Date: 1999/10/05
Message-ID: <uRhK3.4157$lE.22937@ozemail.com.au>
X-Deja-AN: 532979645
Distribution: world
X-Priority: 3
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300
X-Trace: ozemail.com.au 939108826 210.84.139.248 (Tue, 05 Oct 1999 17:33:46 EST)
Organization: OzEmail Ltd, Australia
X-MSMail-Priority: Normal
NNTP-Posting-Date: Tue, 05 Oct 1999 17:33:46 EST
Newsgroups: bit.listserv.sqlinfo