Re: writing SQL statement
Quote:
So I want the SQL statement to return only the 2records having ArticleID=13 and 15 because the other 2 records are not assigned a value in the Flag field
Sorry I want to correct my question:
I want to display the records having ArticleID=13 and ArticleID=14
Re: writing SQL statement
SELECT fields FROM tablename WHERE `int` <> NULL
(Or it might be IS NOT NULL. Not sure)
Re: writing SQL statement
SELECT * FROM [TABLE NAME] WHERE ArticleID=13 OR ArticleID=14
Re: writing SQL statement
If this is MS SQL Server then whenever you check the FLAG field for a value in a where clause wrap it in the ISNULL function
Code:
Where IsNull(Flag,0)<>0
This function takes a column (the first parameter) and if it is null replaces it's value with the second column (in this case I specified 0).
Fields that can contain a NULL cannot be easily checked in a WHERE clause, due to the way NULL is never "equal" to anything, thus is "not equal" to everything (or something like that - it's a bit early here!).
Some people say to use the COALESCE() function instead of ISNULL() in order to remain ANSI-standard, but I prefer ISNULL myself.
Why are you allowing NULL values in this column? Why not make the value 0 anyway?