We are using postgres on yugabyte 2.8.3
Does yugabyte support IN
operator using YSQL syntax?
something like…DELETE FROM Customers WHERE Country IN ('Germany', 'France', 'UK');
RHS is array in our case
We are using postgres on yugabyte 2.8.3
Does yugabyte support IN
operator using YSQL syntax?
something like…DELETE FROM Customers WHERE Country IN ('Germany', 'France', 'UK');
RHS is array in our case
Hi Sham,
Yes of course, try this:
create table Customers as
select * from unnest(array['Germany', 'France', 'UK','Switzerland']) Customers(Country);
DELETE FROM Customers WHERE Country IN ('Germany', 'France', 'UK');
Result: YugabyteDB 2.8 | db<>fiddle
Franck
@FranckPachot
But the yugabyte documentation says,
IN should be applied on records but not array
The combination = ANY
is functionally equivalent to IN
(but IN
is illegal syntax when the RHS is an array).
Yes because IN operates on a set. But you can transform an array to a set with UNNEST if you need to:
WHERE Country IN (select unnest(array['Germany', 'France', 'UK']));