When to use the IN operator in your SQL WHERE statement

Finding your SQL statements growing and difficult to understand? Inherited some code that contains complex looking SQL statements? Let me show you one way to make them easier to read and understand… Sooner or later you will have to create a SQL statement with multiple WHERE conditions, usually AND and OR’s. If you have three […]

How to use PDO to UPDATE data in MySQL using PHP

You need to get data safely updated from a web page to a MySQL table in your database You need to sanitize that data from user input and protect against SQL injections. The following simple example will show you how to accomplish that. These are the ingredients you will need: A MySQL database A table […]

How to use PDO to DELETE data from MySQL using PHP

You need to delete data safely from a web page and your MySQL table in your database You need to sanitize that data from user input and protect against SQL injections. The following simple example will show you how to accomplish that. These are the ingredients you will need: A MySQL database A table to […]

How to use PDO to INSERT data into MySQL using PHP

You need to get data safely from a web page to a MySQL table in your database You need to sanitize that data from user input and protect against SQL injections. The following simple example will show you how to accomplish that. These are the ingredients you will need: A MySQL database A table to […]

How to use PDO to SELECT data from MySQL using PHP example

You have a MySQL table of data in your database, you want to display it on a webpage, so it can be displayed and viewed by other people. You need to have a few things in order to accomplish this: A MySQL database A table containing data in the above database The credentials to above […]

How to INNER JOIN on the same table twice in SQL statement

Having more than one INNER JOIN to the same table can be confusing. More than one INNER JOIN can create a messy SQL statement. If you don’t use aliases they can become difficult to read. So join them with aliases, as explained below. For example say you have the following two tables: Users and Products. […]

What alternatives database engines are there to MySQL?

Unsure what alternatives there are to MySQL? Looking for increases in MySQL performance? You might not realize that there are some compatible relational database engines. That you can drop in to replace MySQL. You can even run SQLite without needing a server stack. SQLite is the most widely deployed database engine in the world Each […]

How to join a table many times in a single SQL query statement?

Having more than one join to the same table within a query can be confusing. More than one join can create a messy SQL statement. If you don’t use aliases they can be difficult to read. If your database tables need to have many columns with the same relationship to another table. You can join […]

Reasons to switch from MySQL to MariaDB

Thinking of moving from regular MySQL to MariaDB? MariaDB has a considerable performance gain over MySQL 5.6 Need any more reasons than performance to switch? Switching from MySQL to MariaDB is easy, it’s still considered a drop in replacement. MariaDB definitely has more of an open source attitude. Galera implementation is better. Maria comes by […]

How to join the same table three times in a single SQL query statement?

Having more than one join to the same table can be confusing. More than one join can quickly create a messy SQL statement. If you don’t use aliases they can quickly become difficult to read. If your database tables need to have three or more columns with the same relationship to another table. You can […]