Re: Row count in a query
| From: | Martín Marqués | Date: | Sat, 31 Jan 2004 17:00:40 +0000 |
| Subject: | Re: Row count in a query | ||
| References: | 1 2 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-32738@lists.php.net to get a copy of this message | ||
El Dom 01 Feb 2004 12:54, John W. Holmes escribió:
> Shaun wrote:
>
> > Is it possible to have an incrementing row count in my query that is not
> > part of the table data?
> >
> > i.e.
> >
> > 1 data data
> > 2 data data
> > 3 data data
> > ...
> >
> > This has to be done in the query not the PHP!!
>
> If you _have_ to get this in your query I'd say you have a flaw in your
> logic somewhere. However, you can do it in MySQL using these two queries.
>
> SELECT @a:=0;
>
> SELECT @a:=@a+1, * FROM table;
This isn't very good SQL coding.
If you use a database with sequences, built a temptable to put the data in
temporarly, with an INT field at the begining, and a sequence to have the
autoincremental.
Very easy, and compatile with any relational DB. :-)
--
select 'mmarques' || '@' || 'unl.edu.ar' AS email;
---------------------------------------------------------
Martín Marqués | Programador, DBA
Centro de Telemática | Administrador
Universidad Nacional
del Litoral
---------------------------------------------------------