|
-
Nov 26th, 2007, 02:52 AM
#1
Thread Starter
Hyperactive Member
[RESOLVED] [sql express 2005] cannot obtain record in opposite way
SQL Code:
SELECT dbo.MWorkOrder.MWORefNo, dbo.MWorkOrder.PWORefNo, dbo.MWorkOrder.DateOfService, dbo.MWorkOrder.Remarks, dbo.WOList.Category,
dbo.WOList.Dept, dbo.WOList.Mac_Code, dbo.WOList.Status, dbo.BreakDownReport.BRRefNo
FROM dbo.WOList INNER JOIN
dbo.MWorkOrder ON dbo.WOList.Ref_No = dbo.MWorkOrder.PWORefNo LEFT OUTER JOIN
dbo.BreakDownReport ON dbo.BreakDownReport.MWORefNo = dbo.MWorkOrder.MWORefNo
WHERE Status = 'Completed' AND Category LIKE '%' AND dbo.BreakDownReport.BRRefNo <> 'Null' ORDER BY dbo.MWorkOrder.MWORefNo
RETURN ME CORRECT RECORD WHICH dbo.BreakDownReport.BRRefNo <> 'Null'But why the SQL BELOW cannot return me the record where dbo.BreakDownReport.BRRefNo = 'Null'
SQL Code:
SELECT dbo.MWorkOrder.MWORefNo, dbo.MWorkOrder.PWORefNo, dbo.MWorkOrder.DateOfService, dbo.MWorkOrder.Remarks, dbo.WOList.Category,
dbo.WOList.Dept, dbo.WOList.Mac_Code, dbo.WOList.Status, dbo.BreakDownReport.BRRefNo
FROM dbo.WOList INNER JOIN
dbo.MWorkOrder ON dbo.WOList.Ref_No = dbo.MWorkOrder.PWORefNo LEFT OUTER JOIN
dbo.BreakDownReport ON dbo.BreakDownReport.MWORefNo = dbo.MWorkOrder.MWORefNo
WHERE Status = 'Completed' AND Category LIKE '%' AND dbo.BreakDownReport.BRRefNo = 'Null' ORDER BY dbo.MWorkOrder.MWORefNo
THANKS FOR HELPS !!
Where there is no hope, there can be no endeavor.
There are two ways of rising in the world, either by your own industry or by the folly of others.
-
Nov 26th, 2007, 07:23 AM
#2
Re: [sql express 2005] cannot obtain record in opposite way
= NULL is not valid SQL . = 'NULL' will expect to look to the word NULL in a text field. To test to NULL you use the Is NULL expression
sql Code:
SELECT dbo.MWorkOrder.MWORefNo, dbo.MWorkOrder.PWORefNo, dbo.MWorkOrder.DateOfService, dbo.MWorkOrder.Remarks, dbo.WOList.Category, dbo.WOList.Dept, dbo.WOList.Mac_Code, dbo.WOList.STATUS, dbo.BreakDownReport.BRRefNoFROM dbo.WOList INNER JOIN dbo.MWorkOrder ON dbo.WOList.Ref_No = dbo.MWorkOrder.PWORefNo LEFT OUTER JOIN dbo.BreakDownReport ON dbo.BreakDownReport.MWORefNo = dbo.MWorkOrder.MWORefNoWHERE STATUS = 'Completed' AND Category LIKE '%' AND dbo.BreakDownReport.BRRefNo IS NULL ORDER BY dbo.MWorkOrder.MWORefNo
Sometimes the Programmer
Sometimes the DBA
Mazz1
-
Nov 26th, 2007, 07:07 PM
#3
Thread Starter
Hyperactive Member
Re: [sql express 2005] cannot obtain record in opposite way
Thanks Sir, you solved my problem ...
Where there is no hope, there can be no endeavor.
There are two ways of rising in the world, either by your own industry or by the folly of others.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|