View Full Version : New row but duplicate cols
I have never run into a situation like this before, but my client wants to create a new row in our database based off an already created row.
The only difference between the two is going to be its description column..
So is there a way to include certain columns from a different row into this newly created row?
Meaning can I have a newly created row include another rows information dynamically so if this other row is edited it will cascade down to this newly created row.
Any ideas?
guelphdad
05-21-2009, 06:57 PM
normalize your data if you are going to allow this. separate the primary key and the comments column into a new table, then you only add the id and new comment.
what use is the duplicated info though and how do you choose to show one row instead of the other with your current setup?
Sorry should of explained a bit more.
We have a series of products that are under very specific categories.
A few products make it into one or two categories. These products that are beings displayed in more than one category still link to its original or rather parent category.
I have been presented with another product that is going to be displayed in two categories, but this time things are different because they both truly belong to its displayed category.. God I can already see your eyes glazing over with HUH?
Basically now that this single product is being displayed in two categories and both are truly independently belonging to each category I have to keep track of two prices for the same product... even though they are the same price..
So if both rows that belong to different categories could somehow rely on either one or the others price column I would only have to maintain one products price and life would be simple again..
Just a heads up, the structure of it all is far to complex to break down and move product pricing to a new data table, trust me I have already been down this road.
guelphdad
05-21-2009, 07:43 PM
say you have three columns id, price, somethingelse
you can do:
INSERT INTO
yourtablename
SELECT
id,
price,
'anotherthing'
FROM
yourtablename
WHERE
id=54
the 'anotherthing' in quotes can be a new value you are entering for that column that doesn't already exist in the table.
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.