samedi 28 août 2021

How to join a "IN" result and check "where" active = 1?

In my query I check if tokens.id exists in dapp_tokens. I want to add that the result in dapp_tokens also has to be active = 1 in the dapps table. So I need to join the dapps table of the row with tokens.id that has been found in dapp_tokens but how can I do that in Raw SQL?

$data['tokens'] = Token::where('active', 1)
            ->whereRaw('tokens.id in (select token_id from dapp_tokens where active = ?)', [1])
            ->sortable('market_cap')->orderby('id','desc')->paginate($page_count);


via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire