How to Concatenate Multiple columns in MySQL

In this tutorial, I show how you can concatenate multiple columns in MySQL.

You can simply do this programmatically by separately select fields from MySQL Table and store their values in the single variable after concat their values.

But you can make the above process a little simpler by concatenating the values while selecting rows from DataBase Table.

Let’s take a simple example –

You have two columns – firstname, lastname within your DataBase Table you want to show both the columns values in a single string form. In this case, you can use MySQL functions to combine the values of the columns.

There are two functions for doing this –

  • CONCAT
  • CONCAT_WS

Both functions work similarly but have little difference.

How to Concatenate Multiple columns in MySQL

Read more

MySQL – Convert Unix Timestamp to Date Time

The Unix Timestamp, while efficient for data storage, lacks human readability and appears as a set of integer numbers to users. To make it more user-friendly, it requires conversion into a readable format before displaying it to end-users.

If you don’t perform this conversion directly while selecting rows from the Database Table, you’ll need to handle it programmatically. For example, in PHP, you can utilize the date() function for conversion like so:

$timestamp = 1690768832;
echo "date time : ".date('d-M-Y H:i:s a',$timestamp);

The above code gives the following output:

date time : 31-Jul-2023 02:00:32 am

In this tutorial, we will explore how to convert Unix Timestamp values into a more readable Date Time format when selecting data from a MySQL Database Table. Let’s dive in and make the process of converting Unix Timestamps more accessible and comprehensible.

MySQL - Convert Unix Timestamp to Date Time

Read more

How to include HTML page with jQuery

If you’re familiar with PHP, you can efficiently embed another PHP or HTML file within your page using include and require statements. This approach saves time, particularly when you need to incorporate the same line of code across multiple files.

However, if you’re not utilizing server-side scripts on your webpage, alternatives such as iframes or client-side scripting languages can be employed.

In jQuery, there exist two primary methods for including a file within another HTML file:

1. AJAX request
2. .load() method

How to include HTML page with jQuery

Read more

How to Use before() and after() method in jQuery

In CSS before and after pseudo-elements use to add style to the targeted selector elements.

There are two methods with a similar name in jQuery.

They adjust the position or add the element before and after instead of changing CSS.

In this tutorial, with examples, I show how you can use before() and after() methods on your webpage.

How to Use before() and after() method in jQuery

Read more