Posts tagged with “select

Using MySQL DATE_SUB to SELECT rows relative to a date range

DATE_SUB can be very handy if you’re trying to return rows from a database table relative to a date range. As the name suggests, it SUBtracts a time value from a DATE. It expects a date, as well as an INTERVAL argument consisting of a unit (such as DAY, WEEK, or YEAR) and quantity, like […]

Using SELECT in a MySQL INSERT Command

I wrote recently about using JOIN when needing to incorporate a lookup in a MySQL delete command. What if one needs to do the same when inserting into a table instead? This time it’s SELECT to the rescue. Imagine we have a simple bookmarking function that stores a user id and article id in a […]