Results 1 to 2 of 2

Thread: Mysql Query ????????

  1. #1
    Join Date
    Jul 2003
    Posts
    9

    Question Mysql Query ????????

    Here is data tables in mysql;

    Function_ID | Domain_ID | Order_No |
    +-------------+-----------+----------+
    | 1 | 3 | 1 |
    | 2 | 6 | 1 |
    | 3 | 4 | 1 |
    | 5 | 4 | 1 |
    | 6 | 6 | 1 |
    | 7 | 4 | 1 |
    | 8 | 5 | 1 |
    | 10 | 3 | 1 |
    | 11 | 3 | 1 |
    | 12 | 3 | 1 |
    | 13 | 3 | 1 |
    | 14 | 4 | 1 |
    | 15 | 6 | 1 |
    | 16 | 5 | 1 |
    | 17 | 5 | 1 |
    | 18 | 4 | 1 |
    | 3 | 3 | 2 |
    | 5 | 3 | 2 |
    | 6 | 6 | 2 |
    | 7 | 3 | 2 |
    | 10 | 2 | 2 |
    | 13 | 3 | 2 |
    | 14 | 3 | 2 |
    | 15 | 2 | 2 |
    | 16 | 3 | 2 |
    | 18 | 3 | 2 |
    | 13 | 3 | 3 |
    | 15 | 4 | 3 |
    +-------------+-----------+----------

    I am looking for a query which will give the unique Function_ID that appears only once in the table, i.e.
    Function_ID | Domain_ID | Order_No |
    | 1 | 3 | 1 |
    | 2 | 6 | 1 |
    | 8 | 5 | 1 |
    | 11 | 3 | 1 |

    and so on.

    Can you tell me the query?

  2. #2
    Join Date
    Nov 2002
    Location
    New Jersey, USA
    Posts
    3,932
    Does your mssql support subquery?. if yes, then you can use this.


    select function_id,
    domain_id, order_no
    from yourtable
    where function_id in
    (select function_id
    from yourtable
    group by function_id
    having count(*) = 1)

Posting Permissions

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