Is there a mysql syntax that can preform a select values from a table, then copy those values into the same table, but update a few columns of the copy?
Table (tickets), id is primary key, auto_increment:
id | name | start_date | end_date | value | active
- Select a single row from tickets given a few values like
name,start_date,end_dateandvalue - Copy the row that matches the statement but update the value by
x - Insert the copy with the update
This will insert a copy of any row(s) matching the criteria in the SELECT..WHERE statement, with the new row(s) having their prim key id autogenerated as per your spec.
If it was a matter of just needing to update -but not copy- rows that match certain criteria then obviously you’d just use an UPDATE statement