RE: quick mysql question

  • From: "Homme, James" <james.homme@xxxxxxxxxxxx>
  • To: "programmingblind@xxxxxxxxxxxxx" <programmingblind@xxxxxxxxxxxxx>
  • Date: Wed, 8 Apr 2009 07:02:26 -0400

Hi,
I forget the syntax, so please check on this. If you want to know how many 
records there are in a table, you would use this.

Select count(*) from <table>;

Where <table> is the name of your table.

I don't know how to figure out which row you are on at the current time.

Thanks.

Jim

-----Original Message-----
From: programmingblind-bounce@xxxxxxxxxxxxx 
[mailto:programmingblind-bounce@xxxxxxxxxxxxx] On Behalf Of Alex Hall
Sent: Tuesday, April 07, 2009 11:22 PM
To: programmingblind@xxxxxxxxxxxxx
Subject: Re: quick mysql question

Okay, so the numbering is lost if you delete.  Is there a more
robust way of numbering, so that you would have gotten:
1, abc'
2, 'ghi'
3, 'kno'
instead? I need the index of each record to always be sequential
so that I can know how many total records there are and also know
which ones I have used in the displaying of all of them.

Have a great day,
Alex

> ----- Original Message -----
>From: "R.  Haynie" <rhaynie@xxxxxxxxxxx
>To: programmingblind@xxxxxxxxxxxxx
>Date sent: Tue, 07 Apr 2009 22:51:24 -0400
>Subject: Re: quick mysql question

>An example is worth a thousand words...

>create table tbl1 (fld1 INTEGER AUTO_INCREMENT,
>fld2 char(3),
>PRIMARY KEY  (fld1));

>insert into tbl1 (fld2) values ('abc'), ('def'), ('ghi'),
('jkl');
>select * from tbl1;
>-- gives you:
>1, 'abc'
>2, 'def'
>3, 'ghi'
>4, 'jkl'

>delete from tbl1 where fld1 in (2, 4);
>insert into tbl1 (fld2) values ('mno');
>select * from tbl1;
>-- gives you:
>1, 'abc'
>3, 'ghi'
>5, 'mno'


>HTH.
>-Rodney




>Alex Hall wrote:
>> Hi all,
>> If I have a table of records and one column is an autoincrement,
what
>> happens when I delete a record? I want to use the autoincrement
as an
>> index, so records 1, 2, 3, and 4 exist where 1-4 are the indexes
of
>> the records, If you delete record 3, do you then have records 1,
2,
>> and 3, or 1, 2, and 4? If it is the second case, is there a
better way
>> to have an index of each record? I need to know how many
recordsI am
>> using on a page (it is sort of a photo viewer so I need to know
which
>> pictures are being shown and how many more there are) and how
many
>> total there are to go.  Thanks.

>> Have a great day,
>> Alex
>> __________
>> View the list's information and change your settings at
>> //www.freelists.org/list/programmingblind



>__________
>View the list's information and change your settings at
>//www.freelists.org/list/programmingblind

__________
View the list's information and change your settings at
//www.freelists.org/list/programmingblind


This e-mail and any attachments to it are confidential and are intended solely 
for use of the individual or entity to whom they are addressed.  If you have 
received this e-mail in error, please notify the sender immediately and then 
delete it.  If you are not the intended recipient, you must not keep, use, 
disclose, copy or distribute this e-mail without the author's prior permission. 
 The views expressed in this e-mail message do not necessarily represent the 
views of Highmark Inc., its subsidiaries, or affiliates.
__________
View the list's information and change your settings at
//www.freelists.org/list/programmingblind

Other related posts: