lundi 27 janvier 2020

How to combine two sql table in laravel 5.8

I am trying to compare two tables to check is user data already exits in another table. I show some posts they talk about whereRaw but details is not enough i was try to run query but i am not getting which i want.

UPDATED I have 2 tables one is for challenges between two people

Challenge Table  id,user_one, user_two, data_one, data_two,winner_id

And my second table is

vote Table id, user_id, battle_id, voted_user

I want to check is user already votes the table or not, If yes skip that challenge table and show remain table data to user.

$challenges = DB::table('challenges')->whereRaw([
            ['challenges.user_one', '!=', $uid],
            ['challenges.id', '!=', 'vote.id'],
        ])->orWhereRaw([
            ['challenges.user_one', '!=', $uid],
            ['challenges.id', '!=', 'vote.id'],
        ])->get();


via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire