I have a table:
ID|user_id|group_id|subject |book_id|duplicate
1| 2 |3 |history |1 |
2| 4 |3 |history |1 |
3| 5 |3 |history |1 |
I want the resulting table to look like this:
ID|user_id|group_id|subject |book_id|duplicate
1| 2 |3 |history |1 |
2| 4 |3 |history |1 |1
3| 5 |3 |history |1 |1
I want all ascending IDs after the lowest ID duplicate column to be updated to 1. PLEASE NOTE: the IDs are dynamic and so simply using ->where(ID, '>', 1); will not work in all cases.
so far I have this
$duplicates = DB::table('table')
->where('subject', 'history')
->where('book_id', 1)
->skip(1)->take(1)
->update(['duplicate' => 1]);
The code above does not work because I get a resulting table that looks like this:
ID|user_id|group_id|subject |book_id|duplicate
1| 2 |3 |history |1 | 1
2| 4 |3 |history |1 |
3| 5 |3 |history |1 |