Results 1 to 5 of 5
  1. #1
    Join Date
    Oct 2004
    Location
    In cousin's house
    Posts
    303

    Unanswered: select fields and create temp field.

    hi,
    Sory, I dont knew how to start but anyway. my problem is somthing like dis.
    I have a table and a field and im using mysql 5.0.3.
    Code:
    table1
    field1 field2
    aaaa test1
    bbbb test3
    cccc test4
    mmmm test7
    lllll test8
    I want a result like dis.
    Code:
    field1 field2 ,tempfield
    aaaa test1 1
    bbbb test3 2
    cccc test4 3
    mmmm test7 4
    lllll test8 5
    thanks ,
    Popskie

  2. #2
    Join Date
    Apr 2005
    Location
    Lier, Belgium
    Posts
    122
    Please be more precise:

    1) what is the sort type and order on which column
    2) what should happen with ties (i.e. when two or more values are the same w.r.t. the sort type and order)

    --
    felix

  3. #3
    Join Date
    Oct 2004
    Location
    In cousin's house
    Posts
    303
    Just in any order in my sample table has just only 2 fields. Pls look at my query.

    select *,_temp_incrementfield from tablename

    but i dont knw how to increment in select statement. Sory for my english.

  4. #4
    Join Date
    Apr 2005
    Location
    Lier, Belgium
    Posts
    122
    Quote Originally Posted by popskie
    Just in any order in my sample table has just only 2 fields. Pls look at my query.
    select *,_temp_incrementfield from tablename
    I meant you need an ORDER BY. E.g.
    Code:
    SET @rank := 0;
    SELECT 
        field1, field2, @rank := @rank+1 
    FROM tablename
    ORDER BY field2;
    --
    felix

  5. #5
    Join Date
    Oct 2004
    Location
    In cousin's house
    Posts
    303
    thats it , nice shoot . Thanks for the rep.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •