Last post Jan 07, 2015 04:30 PM by Afzaal.Ahmad.Zeeshan
Jan 07, 2015 04:21 PM|ayanmesut|LINK
I have a Query which gives the companies. But I need to list the companies with ONLY Video. If the Video field is NOT EMPTY OR NOT NULL, it must be listed.
So for I used IsNullOrEmpty, but I want to get rid of that.
Here is the my code:
var comps2 = data.Query("SELECT CompanyID, CompanyName, Visited, Video FROM Companies ORDER BY Visited DESC").ToList();
How can I do that only using Query (with WHERE clause) without IF code.
Thanx in advance!
Jan 07, 2015 04:29 PM|rrrsr7205|LINK
SELECT CompanyID, CompanyName, Visited, Video FROM Companies
WHERE (video is not null) and Video <> ''
ORDER BY Visited DESC
Jan 07, 2015 04:30 PM|Afzaal.Ahmad.Zeeshan|LINK
You can make a good use of the following command,
var comps2 = data.Query("SELECT CompanyID, CompanyName, Visited, Video
WHERE Video IS NOT NULL
ORDER BY Visited DESC")
This is a IS NOT NULL command, which makes sure that in the rows returned the value for the Video is not a null value. Read this MSDN command for more: http://msdn.microsoft.com/en-us/library/ms188795.aspx