.SELECT General

Object Oriented Style Does Record Exist Simple Get A Result Alternative with check for no result Get Each Row Returned Procedural Style Does Record Exist Simple Get A Result Get Each Row Returned Get Number Of Rows Returned Get Specific Columns Get each field as a variable named as the field Using OR Arguments Putting All […]

Read More

Case Sensitivity

Select is not case sensitive by default SELECT * FROM myTable WHERE ‘something’ = ‘Something’ = 1 To make it case sensitive use a select with binary SELECT * FROM myTable WHERE BINARY ‘something’ = ‘Something’ //or SELECT * FROM myTable WHERE ‘something’ = BINARY ‘Something’ = 0

Read More

DateTime general

ORDER BY Date Order ASC = oldest first DESC = most recent first Note it’s “MINUTE”, “HOUR”, etc not “MINUTES” or “HOURS” etc Convert DateTime to Date Specifying Date and DateTime from a string It is recommended to use CAST() Last Day Of Month (This produces a DATE result, not DATETIME) Get SQL Server’s Current […]

Read More

DateTime SELECT

Date Order ASC = oldest firstDESC = most recent first Date or DateTime from strings Get time difference between now and a DateTime field Argument can be: If DateTime value is Null? You will get a Null value returned from TIMESTAMPDIFF Specifying Returned Date Format Get SQL Server’s Current DateTime Same as Now() but giving […]

Read More

GROUP BY

Get a single result for each MyColumnName value that matches the search criteria For example, say you have multiple rows where MyColumnName=1 that each matches the query, you’ll get back just one result with MyColumnName=1 Same but with an additional field that tells you how many rows matched for each MyColumnName COUNT and GROUP BY […]

Read More

JOIN to get results from 2 tables

Using JOIN to get results from two tables This is PHP4 Code! Example 1 Example 2 Using JOIN to get results from three tables This is PHP4 Code! Example 1 Using GROUP BY To Get One Row Per Match This is PHP4 Code! Note – when using GROUP BY, if you also use ORDER BY […]

Read More