I have a table which contains house details called property. I am creating a localised application, and I have a db table called propertylocalised. In this table is held duplicates of the data and culture column e.g.
key culture propertyname
1 en helloproperty
1 fr bonjourproperty
At the moment I have all my en culture inserted but I want to duplicate all of those rows and then for every other row insert fr into culture.
I obviously only want to do this once, for the purpose of setting up the localisation.
Thanks
Andy
Duplicate rows are a fundamental part of the SQL model of data because the SQL language doesn't really try to implement the relational algebra. SQL uses a bag (multiset)-based algebra instead.
To select duplicate values, you need to create groups of rows with the same values and then select the groups with counts greater than one. You can achieve that by using GROUP BY and a HAVING clause.
Keep duplicate rows Select a column by clicking the column header. To select more than one column contiguously or discontiguously, press Shift+Click or CTRL+Click on each subsequent column. Select Home > Keep Rows > Keep Duplicates.
Generally, duplicate rows are not always allowed in a database or a data table. The regular practice of many companies is to clean their data from such occurrences. However, they are sometimes encountered, especially in new, raw, or uncontrolled data.
INSERT INTO table
SELECT 'fr', propertyname
FROM table
assuming you want to duplicate all the existing records which are all 'en'
insert into propertylocalised select key,'fr'propertyname from propertylocalised where culture = 'en'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With