Skip to main content
Inspiring
November 17, 2008
Question

Query assistance???

  • November 17, 2008
  • 2 replies
  • 358 views
Why would:
select u_fName,u_lName,u_zip,e_foil,u_club,u_uuid,e_foil_rating,e_foil_year,tournevent.e_epee,e_epee_rating,e_epee_year,c_full_name,e_id
from tournfencer
left outer join tournevent on tournfencer.u_id=tournevent.e_id
left outer join tournclub on tournfencer.u_club=tournclub.c_name
where u_email='sgrosz@salleboise.com'

not return anything for the e_foil item requested, but

select u_fName,u_lName,u_zip,e_foil,u_club,u_uuid,e_foil_rating,e_foil_year,tournevent.e_epee,e_epee_rating,e_epee_year,c_full_name,e_id
from tournfencer
left outer join tournevent on tournfencer.u_id=tournevent.e_id
left outer join tournclub on tournfencer.u_club=tournclub.c_name

does return it????


    This topic has been closed for replies.

    2 replies

    Inspiring
    November 17, 2008
    The following effectively becomes an inner join because of the where clause.

    select some fields
    from table1 t1 left join table2 t2 on t1.id = t2.id

    where t2.somefield = something

    To make it work, do this

    select some fields
    from table1 t1 left join table2 t2 on t1.id = t2.id
    and t2.somefield = something

    where etc
    Inspiring
    November 17, 2008
    Hello Dan,

    Thanks for the info, I'll give that a shot.

    > The following effectively becomes an inner join because of the where
    > clause.
    >
    > select some fields
    > from table1 t1 left join table2 t2 on t1.id = t2.id
    > where t2.somefield = something
    >
    > To make it work, do this
    >
    > select some fields
    > from table1 t1 left join table2 t2 on t1.id = t2.id
    > and t2.somefield = something
    > where etc
    >


    Inspiring
    November 17, 2008
    steve grosz wrote:
    > Why would:
    > select
    > u_fName,u_lName,u_zip,e_foil,u_club,u_uuid,e_foil_rating,e_foil_year,tournevent.e_epee,e_epee_rating,e_epee_year,c_full_name,e_id
    > from tournfencer
    > left outer join tournevent on tournfencer.u_id=tournevent.e_id
    > left outer join tournclub on tournfencer.u_club=tournclub.c_name
    > where u_email='sgrosz@salleboise.com'
    > not return anything for the e_foil item requested, but
    >
    > select
    > u_fName,u_lName,u_zip,e_foil,u_club,u_uuid,e_foil_rating,e_foil_year,tournevent.e_epee,e_epee_rating,e_epee_year,c_full_name,e_id
    > from tournfencer
    > left outer join tournevent on tournfencer.u_id=tournevent.e_id
    > left outer join tournclub on tournfencer.u_club=tournclub.c_name
    >
    > does return it????
    >
    >

    There can be strangeness when using WHERE clauses with outer joins. It
    resolves around the relationships between the tables and the fields and
    does these joins cause any NULLS. A null is *always* false and can
    never be matched except with IS NULL functions.

    A Google search for this would provide much better explanations then I
    can provide.