"SELECT * FROM tblTest"
"SELECT SupplierID, CompanyName FROM dbo.Suppliers;"
"SELECT AuthorID, LastName, FirstName FROM Authors"
"SELECT * FROM tblUsers WHERE UserId=" + Convert::ToString(UserId)
WHERE

Multiple SELECT’s


"SELECT SomeColumnName, SomeOtherColumnName FROM SomeTableName WHERE ...

SELECT AS


"SELECT SomeColumnName AS 'The Name I Want To Use' FROM SomeTableName WHERE ...

Multiple WHERE’s


"SELECT * FROM SomeTableName WHERE SomeColumnName=24 AND SomeColumnName=15"

NULL Records


"SELECT * FROM tblUsers WHERE DeletedDateTime IS NULL ORDER BY UserName ASC";
"SELECT * FROM tblUsers WHERE DeletedDateTime IS NOT NULL ORDER BY UserName ASC";

DateDiff


SqlCommand1->CommandText = "SELECT * FROM tblRecordings WHERE DATEDIFF(second, EndDateTime, '" + StartDateTime->ToString() + "') = 0"; //Datediff seems to work for days etc, but this example just doesn't work for some reason

Matches A Value In A List Of Values


"WHERE MyColumnName IN (1,3,6,8)"
"WHERE MyColumnName IN ('Monday','Wednesday','Saturday')"
"WHERE MyColumnName NOT IN ('Monday','Wednesday','Saturday')"
Feel free to comment if you can add help to this page or point out issues and solutions you have found. I do not provide support on this site, if you need help with a problem head over to stack overflow.

Comments

Your email address will not be published. Required fields are marked *