0

Here is my code i just want to remove duplicate rows but it not execute

 DB::table('competition_participants as t1')
    ->join('competition_participants as t2', 't1.id', '<', 't2.id')
    ->where('t1.user_id','t2.user_id')
    ->where('t1.competition_id','t2.competition_id')
    ->delete();

but when i convert this into a raw query it gives me like this

enter image description here

aynber
  • 22,380
  • 8
  • 50
  • 63
  • 1
    Your comparisons are different between the code and the query. `on t1.id < t2.id` in your Laravel query, but `t1.id > t2.id` in the dump. Also, since you're comparing two columns, then you'll need to use `whereRaw` or `whereColumn`. Otherwise, it's trying to compare the string 't2.user_id' instead of the column name – aynber Jul 07 '22 at 12:54
  • welcome to stackoverflow pallavi! have you taken a [tour] and learn [ask]? i'm not quite sure what you are trying to do. can you provide the sql query you want to write in query builder? anyway, you can always resort to `DB::raw` if you are too bothered to try anything else. – Bagus Tesa Jul 07 '22 at 12:54

0 Answers0