On Mon, Sep 10, 2001 at 03:59:36PM -0500, Sheridan Saint-Michel wrote:
> Well, I played with this a little more and it seems to be acting oddly when
> you first
> call this select unless you set the variable first.  So if the below doesn't
> work try
> actually doing this
> 
> $query="set @count=NULL; select
> tableName.*,if(@count,@count:=@count+1,@count:=1) as inc, from tableName";
> 
> (I also realized that simply having @count as the test value should work as
> it should default to NULL)
> 
> If I don't set it, it just returns 1 on every row.  Anyone know why it is
> doing this?
> (I am Running MySQL 3.23.36)

Thank you very much for your help.  I tried this (well, from the command line,
but I'm sure from within PHP it'll work just fine, too) and it does just what
I want!  I looked in my MySQL book and I found the information on the if()
operator/function.  However, there was no mention in the text about using
variables with the "@" prefix...

Oops, here it is in the online manual that installed with mysql 3.23.36...  I
should have looked there first.

Thanks for your help!

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

Reply via email to