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.
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…
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.
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.
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.
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.
Joins are fundamental concepts in SQL and they are prefer by professionals as they are faster then sub-queries. These 3 easy MySQL examples below are a little effort to let visitors understand difference among Inner join, Left Outer join and Full outer join.
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.
Sometime we face the problems for concatenating of group rows column value in a single string. Group_concat() is a function which help us to achieve this.
There is no rank function in MySQL actually, whenever you need to query rank from table based on some functionality/criteria in MYSQL. But there are simple queries that can be used to perform the same.
Read the article to create query as well as to know about equivalent query for RANK and DENSE_RANK in MySQL.