From: | Roman Neuhauser <neuhauser(at)sigpipe(dot)cz> |
---|---|
To: | "Magnus Naeslund(t)" <mag(at)fbab(dot)net> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: More efficient INs when comparing two columns |
Date: | 2005-09-21 06:51:00 |
Message-ID: | 20050921065100.GB85225@isis.sigpipe.cz |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
# mag(at)fbab(dot)net / 2005-09-20 20:45:21 +0200:
> I was thinking if this was possible in some way..
> I have this table where we have X and Y coordinates, and i need to
> select several in one go.
>
> # select * from xy where (x = 1 and y = 2) or (x = 2 and y = 2);
>
> This works but are not so nice looking.
> It would be nice to be able to do it like this:
>
> # select * from xy where (x, y) in ((1, 2), (2, 2));
>
> But that doesn't work.
> A funny thing is that this works:
>
> # select * from xy where (x, y) = (1, 2);
>
> What's the most efficient way of doing these kind of selects?
You'd need to write that as
(x, y) IN VALUES (1, 2), (2, 2)
Unfortunately, PostgreSQL's support for table value constructors
is very weak.
--
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man. You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991
From | Date | Subject | |
---|---|---|---|
Next Message | aw_contact | 2005-09-21 06:57:58 | pg_index_indrelid_index error, any ideas ?? |
Previous Message | Bjørn T Johansen | 2005-09-21 06:47:02 | Re: Help trying to write my first plpgsql function... |