I'm working on a query in Supabase where I need to select specific columns from a table based on multiple conditions. Specifically, I need to select columns a, b, and c from a table where column e is equal to a specific value (e = e) and at least one of the columns (a, b, or c) is equal to another value. Let's call it g.
SELECT a,b,c
FROM table
WHERE e = e
AND (a = g OR b = g OR c = g);
I'm hoping for something similar to the below:
supabase
.from('table')
.select('a, b, c')
.eq('e', e)
.then(({ data, error }) => {
if (error) {
console.error('Error fetching data:', error.message);
} else {
console.log('Data:', data);
}
});
But additionally with the AND operator query above.
However, this only handles the condition where e = e. How can I incorporate the additional condition where at least one of a, b, or c is equal to g using the AND operator in Supabase?
I've tried using the .or() method within the .eq() method, but I haven't been successful. Can anyone guide me on how to structure this query properly?
Thank you.