Join Query

Results 1 to 2 of 2

Thread: Join Query

  1. #1
    Join Date
    Dec 1969

    Default Join Query

    I have this query where I joining 3 tables, but, I am not getting a result even though I know a record exists. I think this is because one of the fields that I am joining is NULL yet, the same field from the other joined table is NOT. Div_contact table has names and id for Division Contacts only<BR>Cont_contact table has names and id for Controller Contacts only<BR>rate_code1 had fields div_id, cont_id which I am joining on these fields. In some cases, cont_id may be null in the rate_code1 table<BR><BR>It goes like this....<BR><BR>If Request.QueryString("contact") &#060;&#062; 0 Then<BR>strSQLProvcc = "Select distinct r.prov_cc, r.cc_des,, r.p_geo_lev_2, r.cont_id, r.div_id, d.div_id, c.cont_id, c.cont_name as ContactName, d.div_name as DivisionName, r.acct, r.acct_desc, r.acct_lev_5, r.cc_lev_3, r.period "<BR>strSQLProvcc = strSQLProvcc & " FROM rate_code1 r, div_contact d, cont_contact c "<BR>strSQLProvcc = strSQLProvcc & " WHERE r.div_id=d.div_id and c.cont_id=r.cont_id and "<BR>strSQLProvcc = strSQLProvcc & " d.div_id = " & Form_contact<BR><BR><BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: Join Query

    If you are performing a JOIN on two or more tables, you must remember that the condition of the JOIN must be met. c.cont_id MUST equal r.cont_id. If SQL can&#039t find a match then it won&#039t return a record even if your other JOINs do work.<BR>JOIN clauses work much like AND clauses for fields but across tables instead.

Posting Permissions

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