Join Database Tables On Multiple Fields

If you’ve spent much time on back-end development you probably have at least a basic understanding of database joins - what they are and how they work. At a basic level, joins are a mechanism to utilize primary and foreign keys to fetch related information from multiple tables. In most cases we use a single field from each table to make the connection, but what about a situation where a table may have multiple references to another table? Let’s look at a scenario where that may be required and how we can work with it.

Read more »

Dynamic 'Where' Clauses With Parameterized Queries in Node.js and MySQL

Occassionally when writing SQL queries the number of fields that we need to filter on may change depending on user selection. Let’s take a look at how we can build dynamic ‘where’ clauses and the corresponding parameter array to handle this scenario.

Read more »

Performing 'like' Queries Using the MySQL Package in Node.js

The MySQL package is a hugely popular library for working with MySQL from Node.js, and with good reason. It’s performant, easy to use, battle tested, and well documented. I was a bit surprised, however, that the documentation doesn’t show the syntax for performing parameterized ‘like’ queries.

Read more »