Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Duplicate Column Values MySQL

Tags:

mysql

Is there a way I can duplicate a column's values into another column?

IE:

s_id  img_id
1     -
2     -
3     -
4     -

to

s_id  img_id
1     1
2     2
3     3
4     4
like image 569
Yoshiyahu Avatar asked Feb 13 '11 00:02

Yoshiyahu


People also ask

How do I find duplicates in a column in MySQL?

Do a SELECT with a GROUP BY clause. Let's say name is the column you want to find duplicates in: SELECT name, COUNT(*) c FROM table GROUP BY name HAVING c > 1; This will return a result with the name value in the first column, and a count of how many times that value appears in the second.

How do you duplicate a column value?

Go to Home –> Conditional Formatting –> Highlight Cell Rules –> Duplicate Values. In the Duplicate Values dialog box, select Duplicate in the drop down on the left, and specify the format in which you want to highlight the duplicate values.

How do you repeat a value in MySQL?

Find duplicate values in one column First, use the GROUP BY clause to group all rows by the target column, which is the column that you want to check duplicate. Then, use the COUNT() function in the HAVING clause to check if any group have more than 1 element. These groups are duplicate.


1 Answers

UPDATE your_table SET img_id = s_id;
like image 64
Costi Ciudatu Avatar answered Sep 22 '22 06:09

Costi Ciudatu