Re: [PHP] possible to add a record number to a query?

2002-06-13 Thread Jason Wong
On Thursday 13 June 2002 20:27, Jeff Field wrote: I would like to have a column returned in a query that tells you which record I'm looking at? Sort of like an auto_increment? IOW, the query results would look like: record first last 1 johndoe 2 joe blow 3

RE: [PHP] possible to add a record number to a query?

2002-06-13 Thread Jeff Field
Yes, there is a particular reason. The actual query I do pulls information from two tables and has both ORDER BY and GROUP BY clauses. The auto_increment column (think of the query results as a table) will give me the rank of the results. I know how to manipulate the data in PHP to accomplish

Re: [PHP] possible to add a record number to a query?

2002-06-13 Thread Chris Hewitt
Jeff, You don't tell us which database. If its Oracle then there is ROWID. Using some sort of record number is good for linking tables as it a primary/foreign key, but otherwise why would you want it? If you do not have such a field as this at present (and want one), you could always add one

RE: [PHP] possible to add a record number to a query?

2002-06-13 Thread John Holmes
You can do it with two queries. SELECT @a:=0; SELECT @a:=@a+1, * FROM table; This would be better taken to a MySQL list, though. Actually, you never said what DB you were using. This works in MySQL. ---John Holmes... -Original Message- From: Jeff Field [mailto:[EMAIL PROTECTED]]

RE: [PHP] possible to add a record number to a query?

2002-06-13 Thread John Holmes
You can use SET @a=0; Instead of the first SELECT, too. ---John Holmes... -Original Message- From: John Holmes [mailto:[EMAIL PROTECTED]] Sent: Thursday, June 13, 2002 12:44 PM To: [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: RE: [PHP] possible to add a record number to a query?

RE: [PHP] possible to add a record number to a query?

2002-06-13 Thread Jeff Field
1) Yes, I'm using MySQL 2) You're right. This is not a PHP question. My apologies to the list! Thanks for the feedback! I'll give it a try (and the other one in the other email). Jeff -Original Message- From: John Holmes [mailto:[EMAIL PROTECTED]] Sent: Thursday, June 13, 2002

RE: [PHP] possible to add a record number to a query?

2002-06-13 Thread David Freeman
I would like to have a column returned in a query that tells you which record I'm looking at? Sort of like an auto_increment? IOW, the query results would look like: record first last 1 johndoe 2 joe blow 3 carol fisher The table