Replicate Record in MySQL

Programming for Search Engines 101. An area for avid PHP and .NET developers to chat about Programming techniques and how to make better use of search engines.

Moderator: Moderators

Replicate Record in MySQL

Postby douglas » Thu Apr 11, 2013 12:26 am

We can duplicate records in our MySQL table using SELECT COUNT(*) FROM YOUR_TABLE;

INSERT INTO YOUR_TABLE
SELECT *
FROM YOUR_TABLE
WHERE COUNT =(SELECT COUNT(*)
FROM YOUR_TABLE);

Duplicate record is only possible if your table has no primary key as primary key will not allow duplicates otherwise its ok to duplicate record.
douglas
 
Posts: 282
Joined: Fri Feb 20, 2009 3:56 am

Re: Replicate Record in MySQL

Postby silvester » Thu Apr 11, 2013 2:11 am

This type of SQL statement is helpful when we are fetching entire row from one table and inserting to another for ex:-in e-commerce projects. Need to make sure that the fields in both table are same.
silvester
 
Posts: 89
Joined: Mon Nov 10, 2008 12:59 am


Return to Programming

Who is online

Users browsing this forum: No registered users and 6 guests