The following shows how use a simple SQL statement to create a list of unique values and a count of their occurrences from a table. For example, if we had…
If you're building a string using an SQL statement, you can split results with "new lines" using CHAR() to insert the ASCII line break character into your string. For example,…
When building complicated SQL statements often I will make use of a SELECT - FOR XML PATH statement to concatenate many results into a single string. For example SELECT STUFF(…
Problem If you try to use a column alias in a where statement, you receive an error message that reads "Invalid column name 'myAlias'." For example, this statement will give…
You may already know to prepare your SQL queries using $wpdb->prepare but what you may not know is it's unnesecary if the SQL query doesn't use any parameters. In fact,…
I recently needed to re-do my image thumbnails inside all WordPress posts. I decided to use phpMyAdmin to run a SQL query to list all posts with thumbnails, then individually…
The following example shows how to use a regular expression (a regex) to search for information in an SQL database. The regular expression used looks for images which end with…
I recently needed to set a default option for a SELECT drop down list. As you probably already know, select elements do not support a default value, but you can…
Internet Explorer does not support using the 'display: none' style on OPTION elements inside a SELECT list. For example, the below would work in FireFox and Google Chrome but not…