Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2004
    Location
    manila
    Posts
    9

    Unanswered: query select: compare 2 tables?

    hi good day to all.

    im using postgreSQL7.3.2 in RH7.3

    my question is how can i check if an item exist from the other?
    let say i have tables party_list_votes and party_list_orgs
    i want to check which part_list does not exist from party_list_votes based on party_list_orgs table?
    i have in mind like this query but i know it does not gonna work. iL post anyway to give you more idea how u can help me..
    QUERY:
    SELECT * FROM party_list_votes WHERE municity_code = '980110600' NOT IN (SELECT party_id FROM party_list_orgs);

    anyone has idea or suggestion to solve my prob will greatly appreciated. thanks you.

    chris

  2. #2
    Join Date
    Sep 2002
    Location
    Toronto, Canada
    Posts
    76

    Re: query select: compare 2 tables?

    Originally posted by vickr1z
    hi good day to all.

    im using postgreSQL7.3.2 in RH7.3

    my question is how can i check if an item exist from the other?
    let say i have tables party_list_votes and party_list_orgs
    i want to check which part_list does not exist from party_list_votes based on party_list_orgs table?
    i have in mind like this query but i know it does not gonna work. iL post anyway to give you more idea how u can help me..
    QUERY:
    SELECT * FROM party_list_votes WHERE municity_code = '980110600' NOT IN (SELECT party_id FROM party_list_orgs);

    anyone has idea or suggestion to solve my prob will greatly appreciated. thanks you.

    chris
    The above query would not work.

    It would be helpful, if we know what fields were in each table. How about
    'SELECT * FROM party_list_votes WHERE NOT EXISTS ( SELECT 1 FROM party_list_orgs where party_list_orgs.id = party_list_votes_id)'

  3. #3
    Join Date
    Mar 2004
    Location
    manila
    Posts
    9
    Hi again thanks for your help.
    i figured it out alredy how to solve my prob.

    this is the query i used.:

    select party_id from party_list_orgs not in (select party_list from party_list_votes where municipality_code = '980106000');

    which mean im comparing the masterlist of party from encoding table party_list_votes.

Posting Permissions

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