Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2010
    Posts
    12

    Unanswered: Please Help on a Join Query!!!

    Hi All,


    I have a table with following structure;

    Table 1
    ---------------------------------------------------------------
    ID | Zone | Area | Indicator | Value | Timestamp | Collector_ID
    ----------------------------------------------------------------


    Collector_ID is a foreign key from another table of the following structure;
    Table 2
    ----------------------------------------------------------------------------
    ID | Collector_Name | Filename | Collection_Time | Added_at
    ----------------------------------------------------------------------------



    I am trying to write a join query that will give me all the records from table 1 joining it with table two where collector_name contains "Agent_A" or "Agent_B.

    Here is what i have been trying with:


    select * from table_1 as one
    inner join
    table_2 as two
    on one.collector_id = two.id

    where
    two.collector_name like %Agent_A% or
    two.collector_name like %Agent_B% ;



    Please help me to find errors or guide me if I am completely wrong.

    Thank you very much!
    Last edited by sysenm; 11-10-10 at 06:11.

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Quote Originally Posted by sysenm View Post
    Please help me to find errors
    you know, the best way to find the errors is to actually run the query and see what happens
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Dec 2007
    Location
    Richmond, VA
    Posts
    1,328
    Provided Answers: 5
    I am trying to write a join query that will give me all the records from table 1 joining it with table two where collector_name contains "Agent_A" or "Agent_B.
    Based on your description sounds like you would want to use a LEFT OUTER Join.

    Dave

Posting Permissions

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