Tag Archives: sql

SQL: Toggle 1 and 0 Value in an Update SQL Statement

I tend to use a lot of tinyint columns as controllers for my database-held objects, usually sticking to the convention of 1 means on and 0 means off. In other words, the perfect target for a SQL toggle statement! Continue reading

Posted in MySQL, Tutorials | Tagged 1 or 0, , , | View Comments

SQL: Finding Duplicate Rows based on Multiple Columns

Locating duplicate rows based on multiple column values with SQL turns out to be a fairly simple exercise. Continue reading

Posted in Technology & Code, Tutorials | Tagged , , , , , | View Comments

MySQL: Prevent Two PHP Scripts from Overwriting One Another’s Table Updates

One of the main ways of dealing with this is to use “locks”, basically allowing one script to lock a particular set of tables, meaning that other scripts can’t make use of those tables until the locks are released. Continue reading

Posted in Technology & Code, Tutorials | Tagged , , , , , , , table lock | View Comments

SQL: Add a Unique Compound Key to an Existing MySQL Table

A simple question for today: how does one go about preventing duplicate rows based on the value held by more than one column being inserted into an existing MySQL table? Continue reading

Posted in Technology & Code, Tutorials | Tagged , , , , , , | View Comments

Why Does FOUND_ROWS() Keep Returning 1?

It turns out that there exists an acknowledged bug that if the PHP .ini setting of mysql.trace_mode is set to true, i.e. on, FOUND_ROWS() will always return 1. Continue reading

Posted in Technology & Code | Tagged , , , , , , | View Comments
Navigation »