lundi 25 avril 2022

Query in rails with where array clause

I have an array field, author_ids in books table, I need to write a query to find the array data.

Is there any way i can get, even if author_ids has [1,3] in its value, but when I check with array [1,5], I still could get the data because it has 1 common ? here('author_ids @> ARRAY[?]::integer[]',[1,5])

where('author_ids @> ARRAY[?]::integer[]',[1,5])

this doesnot return data, where('author_ids @> ARRAY[?]::integer[]',[1,3]) whis does because It has [1,3]. Iwant to get the data where [auther_ids] ? any [passed_aray]

Aucun commentaire:

Enregistrer un commentaire