Categories
Learning Journal

Multiple SQL Inserts in 1 Query

If your MySQL version is 3.22.5 or later, you can now INSERT multiple values / records in one single query. In most cases this is probably not useful but I recently found this out while trying to optimise my GIDTopsites script.

Categories
Learning Journal

Formatting Dates in MySQL

When you want to format dates stored in a MySQL database to output onto your web pages, you have a choice; either do it with PHP or do it directly in the MySQL query itself.

Categories
Learning Journal

Inserting Data in Multiple Tables

How to insert records of data into more than 1 database table in MySQL at a time? When I first started coding PHP scripts for myself, without researching further, I simply assumed that I had to INSERT data into multiple tables by inserting part of the data into 1 table, query that table to get that just inserted data’s record ID and then do another INSERT on the next table and so on.

Categories
Learning Journal

Random Rows in MySQL

I have to admit that I had quite some trouble figuring out how I could get MySQL to return some random rows in a query. It was something I had to figure out for myself when I wanted to get a list of random web sites off GIDTopsites to place on these pages here.