MySQL update if value is greater than current value

While working with MySQL database there might be situation when you wish to update certain column only if the value being updated is greater than existing value or current value stored in that column. MySQL GREATEST and LEAST functions are quite handy in such situations. Let’s see how can we use first function to update a column if value is greater than current value.

Read More

2 ways to truncate foreign key constrained table

In MySQL we create tables and build relationship among them. In the process if we need to truncate foreign key constrained table then we can’t do it simply and MySQL will throw an error even we have already removed table having foreign key constraint:

ERROR 1701 (42000): Cannot truncate a table referenced in a foreign key constraint…

Read More

MySQL insert row if not exists else update record

Sometimes we create MySQL tables which don’t contain auto increment primary key column instead they may have unique key or combination of unique indexes. In such tables we wish to insert a new row if primary/unique key or keys combination doesn’t exists and update record if exists.

Read More

Auto increment non primary key column in phpMyAdmin

In MySQL we might need to auto increment a non primary key field or column in a database table. This might require particularly in cases where we have already set a combination of columns as primary key. So here are steps with images to let you understand how can we make a column as auto increment non primary key column in phpMyAdmin.

Read More

Setting composite primary key in phpMyAdmin

Even wonder how to set mix of two or more MySQL database columns/fields as primary key in phpMyAdmin as there is no direct link during creation of table. This articles with tell you the way to setting composite primary key in phpMyAdmin.

Read More

5 star rating in PHP with AJAX and jQuery

Displaying a star ranking system is a common requirement to implement in websites. We have explained here how can we show a group of stars for each database record and dynamically apply 5 star rating in PHP with AJAX and jQuery. You can make AJAX calls to store rating of the record in database.

Read More

convert time string into time with AM/PM in MySQL

I have the old database in which time was stored as string with AM/PM. One day I required to do some time calculation on that field. I have googled out for convert time string into time with AM/PM in MySQL and found some solution.

Read More

[ Page 1 of 3 ]