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

Apply foreign key in phpMyAdmin using database query

If you already have database tables and you just want to apply foreign keys for record on those table then you can apply foreign key in phpMyAdmin using database query also.

I have already written a tutorial ‘Setting up foreign key in phpMyAdmin‘ with example images and I prefer to write database query to set up foreign key in existing database tables as queries allow me to accomplish all required steps in once go.

Read More

Query to obtain rank function in MySQL

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.

Read More

Concatenate multiple MySQL rows into one field using GROUP_CONCAT

We can concatenate multiple MySQL rows into one field using GROUP_CONCAT function in mySQL query. There might be situations when you select multiple values from multiple tables and after all the joins you have got a lot of rows than you would like. We can use`GROUP_CONCAT` to obtain the same result with less numbers of rows.

Read More

Get the last inserted ID of a MySQL table in PHP

Get the last inserted ID of a MySQL table is a simple query to obtain the primary key of the record you just inserted to the table. Here I have explained the query using PDO as well as Mysqli.

Also, I have abbreviated few points while using PDO or if you are trying to get the last inserted ID of a MySQL table in PHP using other methods.

Read More

Display Data in Multiple Columns from Database using PHP

In some scenario we need to display data in multiple columns in a HTML table where each row from database keeps data for a single column. The data can be text, image or mixture of both. This article will guide you display data in multiple columns from database using PHP.

Read More

Sum of multiple columns values in a row

With help of the following simple query you can find sum of multiple columns values in a row.

In the `marks` table below we have roll number and marks of each student in physics, chemistry and maths. Now we wish to find sum of marks obtained by each student.

Read More

[ Page 2 of 3 ]