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);
source https://stackoverflow.com/questions/68964074/how-to-join-a-in-result-and-check-where-active-1
Comments
Post a Comment