Hi. I need to do something like this:

SELECT row_nr, * FROM asdf LIMIT 10

The column row_nr should be 1, 2, 3 ... 10, but row_nr is NOT a value in the table, I need it to be "generated" some way in the query.

The reason is that I want to do something like INSERT INTO table SELECT row_nr, * FROM .... and so on, And I need every one of those queries to be numerated (in row_nr) starting from 1 and going to as many rows as the query results in.

Does anyone know how to solve this one?

Thanks. /Christian

    LoganK wrote:

    Auto-increment.

    Thank you for your answer, but you clearly did not undertstand the question. The increment does not exist in any column. I need a virtual count created directly in the query.

      What could be the use of a "virtual count"?

        LoganK wrote:

        What could be the use of a "virtual count"?

        Does it matter?

          If I don't know the context in which it's being used, I don't know how I can help you get it done. It'd be like me going up to a teacher and saying, "I want you teach me a subject." "Which one?" "Does it matter?" Without context it's hard to understand something.

            LoganK wrote:

            If I don't know the context in which it's being used, I don't know how I can help you get it done. It'd be like me going up to a teacher and saying, "I want you teach me a subject." "Which one?" "Does it matter?" Without context it's hard to understand something.

            You dont need the context, I've explained enough.

            Anyway, I have another solution to the problem, and I dont need the count in the query any more...

              Allright...please mark the thread resolved.

                Write a Reply...