MySql : How to copy records from one table to another

MySql : How to Copy records from one table to another


Mysql is one of the most used databases in the world. It is proved with the number of websites using MySql as their database system, and today, the most popular Content Management Systems including Worpdress, Joomla and many other Blogging Platforms are also using MySql. One reason for the popularity of Mysql is it is Free and Open Source. 

So if you are also working with MySql databases, this blog post will be there to help you someday.

Sometimes you may face instances where you want to copy an entire record of a database table to another table

What I am going to show you today is the way of copying a row of a database table to another using a single Mysql query. This is very useful in cases where you want to take a backup record of a row. If the application you are developing has an option to view the update history of a certain record, you can simply do it with this query by copying the whole row to another table.

Note : For this query to work, both the tables must have same fields. 

Example : 
Here We are considering two tables, 'JOBS' and 'JOBS_BACKUP'. Note that both the tables have the same fields and same properties. In this case, the user is updating the Job which has the ID : 8, and I wanted to take a snapshot of the Job details for the job id 8, as how it was before editing. So later if needed, I have the ability to compare the difference between the two versions, and also I will have all the information I need to check which user has made the update, and when the update was done etc. 

INSERT INTO jobs_backup (
job_id,   
cat_id,
user_id,
start_date,
description,
job_location,
date_created,
last_update,
last_editby,
verified
) SELECT
job_id,
cat_id,
user_id,
start_date,
description,
job_location,
date_created,
last_update,
last_editby,
verified
FROM
jobs 
WHERE
job_id = 8;

As a general query, We can rewrite the above again as :

INSERT INTO table_02 (
field_1,   
field_2,
field_3
) SELECT
field_1,
field_2,
field_3
FROM
table_01 
WHERE
field_1 = 'your value';

I hope this would be helpful to someone who is looking for a way to copy database records in between two tables. Please don't forget to share your comments on this post if this was useful to you :

String Length Calculator Online


String Length Calculator Online



Enter the string to calculate the length:



Thank you for using our free online string length calculator Tool.


What is String Length?

String is a general term used in computer / programming technology to represent a line of text, a word, or may be a several number of characters. We use strings very frequently in programming and other programming related stuff. And also, in day to day life there are many instances where we are using strings, but without much noticing. So as I have mentioned, the length of a string may be sometimes very important. What is meant by the term length here is exactly, the number of characters present in the string. It becomes very interesting when it comes to string lengths because usually as human beings we may only think about the number of readable characters available in a string (a word). But when dealing with a computer, the length of a string is not only the number of known characters, but everything the string is made up of including the punctuations, periods and any other special characters.

Is it important to know the string length?

Yes, many people face instances where they want to know the length of a string. Even in real life, you need to think about the string length since we are dealing with many computer related items. For example, when sending a sms you always think about the length of the message, yeah? like wise, we might face many similar instances in our day to day life.

Why using an online string length calculator?

It is not a mandatory thing for you to use a string length calculator online. But since most of us are using Internet very much, it is really easy and hassle free to use an online string length calculator. Besides, who will like to install a software and waste many minutes when you have the ability to get the string length in two seconds. It is easy as that, just copy, paste and our tool will tell you the length of the string in a second.

Why to use this online string length calculator?

One reason is that using this tool is really simple. All you have to do is copy and paste the string in the above textbox, and click on count button. Our calculator will respond to you with the string length in less than a second. No waiting times until the page submits and reloads, like in most other online string length calculate tools. Everything happens super fast. We use a client side Javascipt function to calculate the string length. This kind of a process is really simple to handle and it doesn't need to sent to a server to process and get the string length. There are many tools I have come across which submits the string to the server to calculate the length.

Is this a Javascript String Length Calculator?

This tool uses a simple client side code in Javascript to process the user input (i.e the string in this case) and give out the string length to the user. Since this tool is created using Javascript, both the user and the server end will have many advantages. The main thing is that it doesn't need to be submitted to the server, and hence the server load is not required. Also since there is no submission to the server, the time taken to submit and reload the page is not accountable to the user, so the user will get the output or the string length immediately.

What is the Javascript function used to calculate the string Length?

Here is the function I have used in this tool to calculate the string length. This is made for my own usage, to calculate the length of a string quickly for one of my recent projects. You can use it as you wish, or you may also create your own one. It is really simple to create a small function like this in Javascript :)



string length calculator calculate string length string online online string length calculator text length calculator word count online calculator text parsing tools string size calculator tools word count word count online tool java script word count online string