Re: INSERT ... SELECT Challenge

2007-03-12 Thread Miles Thompson
So with a unique index on ItemI + AttributeID + Attribute_Value, this could be the statement: INSERT INTO bm_ItemsAttributes (ItemID, AttributeID, Attribute_Value) IGNORE SELECT DISTINCT(bmIA1.ItemID) FROM bm__ItemsAttributes bmIA1, '31', 'default text'; which should result in a new row co

Re: INSERT ... SELECT Challenge

2007-03-12 Thread Miles Thompson
So with a unique index on ItemI + AttributeID + Attribute_Value, this could be the statement: INSERT INTO bm_ItemsAttributes (ItemID, AttributeID, Attribute_Value) IGNORE SELECT DISTINCT(bmIA1.ItemID) FROM bm__ItemsAttributes bmIA1, '31', 'default text'; which should result in a new row co

Re: INSERT ... SELECT Challenge

2007-03-12 Thread Brent Baisley
Skip the whol SELECT part an create a unique index on the fields you want unique (AttributeID, Attribute_Value). Then just do an INSERT IGNORE. The index will prevent a new non-unique from being entered and the IGNORE will prevent an error. - Original Message - From: "Miles Thompson" <[