Not IN

  • I am lost on why this query is not showing any missing data. I know it is there I can query specific tracking codes in ebill and they do not exist. When I do this simple select it shows that everything in tbl_tracking exists in ebill. Can any of you see what I am doing wrong? tracking code in tbl_tracking does not allow Nulls where Tracking_Number in ebill allows nulls. There are both set to be varchar 30. If I do an IN it pulls records but not all. So I know some are missing.

    Select * FROM Tbl_Tracking

    WHERE Convert(Varchar(30),[Tracking_Code])

    NOT IN (

    SELECT Convert(varchar (30),Tracking_number)

    FROM Ebill

    )

  • Stupid SQL. It is because there are nulls in tracking number. If I make the nulls 0 then I get all kind of results.

  • That's also why it's better to use outer joins for queries like that .

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply