CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Dec 2004
    Posts
    41

    return null fields ok

    Code:
    select table1.field1, table1.field2, table2.field1, table2.field2
    from table1, table2
    where
    table2.field2 is not null and 
    table2.field2 is not null and
    table2.fieldc = 5 and
    table2.fieldd = table1.fieldd
    group by table1.field1, table1.field2, table2.field1, table2.field2
    this query works if table2.field1 and table2.field2 are not null.
    But, if these fields are null it does returns nothing.

    It is ok if table2.field1, table2.field2 return as null.

    how to modify above query to do this?.

  2. #2
    Join Date
    Apr 2005
    Location
    Norway
    Posts
    3,934

    Re: return null fields ok

    Code:
    select table1.field1, table1.field2, table2.field1, table2.field2
    from table1, table2
    where
    table2.fieldc = 5 and
    table2.fieldd = table1.fieldd
    group by table1.field1, table1.field2, table2.field1, table2.field2
    - petter

  3. #3
    Join Date
    Nov 2004
    Location
    Poland
    Posts
    1,355

    Re: return null fields ok

    It does not make sense to me. U R using "GROUP BY" without any agregate function (like SUM,COUNT etc).There are no errors but it doesn't mean that it works! U can skip "GROUP BY".

    And I don't understand what U are trying to achieve. Is it OUTER JOIN U looking for?

    Best regards,
    Krzemo.

  4. #4
    Join Date
    Jan 2003
    Location
    North Carolina
    Posts
    309

    Re: return null fields ok

    First off let's see what yo are after. Can you post an example of the table data and what yu expect the results to be. Also, you are using the older ansi join syntax method which most databases have moved away from to the newer INNER JOIN, OUTER JOIN options, what system are yu developing against?

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured