See if this does what you are shooting for:

 select tableName.*,if(@count>=1,@count:=@count+1,@count:=1) as inc, from
tableName;

Keep in mind that @count will keep it's value until the thread is closed, so
if for some reason you have
to do the above twice in one thread throw in a statement like:

set @count=Null;

between the selects  =P

Sheridan Saint-Michel
Website Administrator
FoxJet, an ITW Company
www.foxjet.com


----- Original Message -----
From: "Michael George" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, September 10, 2001 2:20 PM
Subject: [PHP] MySQL query help


> I'm trying to make a query that will number it's own output rows.  e.g.
when
> listing all the entries in a table that are related to a specific invoice,
> there will be a column with a monotonically increasing integer value (1-x
> where x is the number of matching entries).
>
> I know I can easily do this with PHP after the query is generated, but I
have
> a generic function to create a pulldown menu selection that will work
easily
> if I can just get that counter column in there...
>
> I've tried:
>
> select tableName.*, 1 as inc, sum( inc ) from tableName;
>
> But sum() will only accept a table column, not a display column...  I have
the
> Widenius MySQL book, but I haven't found anything useful in there.
>
> If anyone has an idea, I'd appreciate it...
>
> -Michael
>
> --
> No, my friend, the way to have good and safe government, is not to trust
it
> all to one, but to divide it among the many, distributing to every one
exactly
> the functions he is competent to.  It is by dividing and subdividing these
> republics from the national one down through all its subordinations, until
it
> ends in the administration of every man's farm by himself; by placing
under
> every one what his own eye may superintend, that all will be done for the
> best.
>                 -- Thomas Jefferson, to Joseph Cabell, 1816
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to