Blog Archives

MySQL Replace – replacing one value with another in a database table

If you need to replace one value with another in a database table field you can do the following: update TABLENAME set FIELDNAME = replace(FIELDNAME, ‘$’, ‘£’) Which would replace $ with £.  

Posted in SQL

Dates in MySQL – select records where date is greater than yesterday

Just found this quite useful: SELECT * FROM `TABLENAME` WHERE FIELDNAME > DATE_SUB( NOW( ) , INTERVAL 1 DAY ) LIMIT 0 , 30  

Posted in SQL

SQL Subselects

Let’s say you’ve got three tables, Cars, Makes, Models. What if you need to get a list of cars including their Make and Model? Here’s where subselects come in. The Tables: Cars ————— id MakeID ModelID Colour ImageLink Makes ———

Posted in SQL