Category Archives: Databases

MySQL: updating one table from another

I always find this a bit awkward, especially if there isn’t a straightforward (i.e. primary key) way of matching records across tables. I find the INNER JOIN syntax easier here — I always do a SELECT using the join criteria … Continue reading

Posted in Databases | Leave a comment

Things I didn’t know about MySQL #1: GREATEST

Somehow I have used SQL for nearly 30 years without knowing about the GREATEST function. It’s only when you need to do something that looks impossible that you delve into the online manual and find gems like this. In this … Continue reading

Posted in Databases | Leave a comment

Book review: PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide, 4th Edition by Larry Ullman

I bought PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (4th Edition) to use as a set book for an online intermediate PHP class that I teach. I previously used Web Database Applications with PHP & MySQL by … Continue reading

Posted in Databases, PHP, Web development | Tagged | Leave a comment

More nifty SQL: insert if not exists

Quite often you want to insert a record into a table, but only if it doesn’t already exist. OK, you could first do a SELECT query to check for existence, and then do the insert, but it’s clumsy and raises … Continue reading

Posted in Databases | Tagged , | Leave a comment

ADODB database abstraction library for PHP

I’ve been using this library for years to make my database interface code database-independent, but I am still discovering new useful functions. Case in point: today I was using the handy rs2csv function, which outputs a recordset to a CSV … Continue reading

Posted in Databases, PHP, Web development | Tagged , | Leave a comment

SQL query to find duplicate rows

This is one of those things I can never remember how to do when I need to do it. I don’t know why, it’s really quite simple: SELECT emailaddress, firstname, lastname, COUNT(emailaddress) FROM customers GROUP BY emailaddress HAVING COUNT(emailaddress) > … Continue reading

Posted in Databases | Tagged , | Leave a comment

Chocs To Go is here!

The goal for students on the intermediate PHP and MySQL course that I’m running for IWA/HWG is to create a working shopping cart. The course starts in only three days, and I decided I’d better walk the walk and prove … Continue reading

Posted in Databases, PHP, Web development | Tagged | Leave a comment

Another handy SQL Server utility

Why doesn’t SQL Server come with a built-in method for generating SQL dump files so you can easily port your data to another database? Microsoft in its own little walled garden I suppose; while the facilities in Enterprise Manager for … Continue reading

Posted in Databases, Web development | Tagged , | Leave a comment

Intermediate PHP and MySQL course

Since 1999 I’ve been teaching online for the Open University. It may not pay brilliantly, but it’s regular income and I really enjoy doing it; OU students often overcome major barriers to achieve a qualification they missed out on earlier … Continue reading

Posted in Databases, PHP, Web development | Tagged , | Leave a comment

Date handling in PHP and MySQL

It’s always a real headache manipulating dates between PHP and MySQL, because PHP’s date functions assume Unix timestamps, while MySQL has its own internal date format. They both have excellent built-in functions for handling dates, but they are fundamentally incompatible. … Continue reading

Posted in Databases, PHP, Web development | Tagged | Leave a comment