Select field twice

Last post 11-02-2009 7:55 AM by ecomite. 2 replies.

Sort Posts:

  • Select field twice

    11-02-2009, 7:01 AM
    • Member
      50 point Member
    • khalid2008
    • Member since 03-10-2008, 12:53 PM
    • Posts 197

    Hi ALL,

    I have a table  that save employee number for flow of approving requests and sequence number for each one

    I want to retrive name of every one who have sequence number 1 and every one who have sequece number 2

    that mean I want to retrive employee number more than one time the same query but with differne condition then

    connect it with other table to get the name

    Please help me ASAP

    khalid

  • Re: Select field twice

    11-02-2009, 7:45 AM
    • Participant
      886 point Participant
    • Babunareshnarra
    • Member since 07-12-2009, 7:10 AM
    • Hyderabad
    • Posts 179

    Use a sub query or

    u can insert the values into a temporary table and can obtain the output using a select query or

    The best option is

    write a select -- case statement

    like

    select case colName when null then ' ' else colname end  from table where _id = _id  )) as retValue


    Hope this helps you

    Regards

    Babu Naresh Narra

    Remember to click “Mark as Answer” on the post If you get answer from my post(s) !
  • Re: Select field twice

    11-02-2009, 7:55 AM
    Answer
    • Member
      210 point Member
    • ecomite
    • Member since 10-05-2009, 4:19 AM
    • Posts 35

    Hi,

    You can use the union all operator:

    select *, '1' as seq from table where sequence=1

    union all

    select *, '2' as seq from table where sequence=2


    The "'1' as seq" in the query is for you to be able to tell the difference in your logic.


    Hope this helps. Please be more specific on the tables structures if it doesn't.

Page 1 of 1 (3 items)