[PHP-DB] Row count in a query

2004-01-31 Thread Shaun
Hi,

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!!

Thanks for your help

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Row count in a query

2004-01-31 Thread Ignatius Reilly
The best way I can think of is:
- create a temporary table T with an autoincrement field + desired output
column structure
- perform a INSERT INTO T SELECT 0,  in the temp table
- you now have the desired result in your temp table

HTH
Ignatius
_
- Original Message -
From: "Shaun" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Saturday, January 31, 2004 11:44
Subject: [PHP-DB] Row count in a query


> Hi,
>
> 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!!
>
> Thanks for your help
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Row count in a query

2004-01-31 Thread John W. Holmes
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:[EMAIL PROTECTED], * FROM table;

--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

php|architect: The Magazine for PHP Professionals – www.phparch.com

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DB] Row count in a query

2004-01-31 Thread Martín Marqués
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:[EMAIL PROTECTED], * 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
-

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Row count in a query

2004-01-31 Thread Ignatius Reilly
Hmmm...

I would not bet money on John Holmes bad coding.
(disclaimer: I have no financial stake in PHP|A, other than being a happy
subscriber)
More likely the original question was not well formulated.

cheers
Ignatius
_
- Original Message -
From: "Martín Marqués" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>; "Shaun" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Saturday, January 31, 2004 18:00
Subject: Re: [PHP-DB] Row count in a query


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:[EMAIL PROTECTED], * 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
-

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Row count in a query

2004-01-31 Thread John W. Holmes
Martín Marqués wrote:
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?
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:[EMAIL PROTECTED], * FROM table;
This isn't very good SQL coding.
Sure it is. It's the question that's not very good.

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. :-)
Exactly. That's why I gave a solution for MySQL.

--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

php|architect: The Magazine for PHP Professionals – www.phparch.com

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php