Of the IN clause under PostgreSQL 9.6 (sqlfiddle.com), both syntax variants
return true without error:

SELECT (1,2) IN ((1,2),(3,4));
SELECT (1,2) IN (VALUES (1,2),(3,4));

A clone of PostgreSQL would also have optional VALUES table alias and
column name specifiers as observed earlier.



On Thu, Jan 18, 2018 at 11:59 AM, petern <peter.nichvolo...@gmail.com>
wrote:

> >I am open to enhancing the syntax here, but not right now because we
> are trying to get the 3.22.0 release out - this would need to be
> during the next cycle.  Also, I'll need to check to see what
> PostgreSQL does first, and emulate them.
>
> Yes please!  Thank you for getting around to this:
>
> (VALUES <column-values>) AS <table-alias> (<column-names>)
>
> In PostgreSQL 9.6 (sqlfiddle.com), apparently where '<table-alias>' is
> specified, 'AS' and '(<column-names>)' are optional.
>
> Reference: https://www.postgresql.org/docs/9.5/static/queries-values.html
>
> ---quote---
>
> By default, PostgreSQL assigns the names column1, column2, etc. to the
> columns of a VALUES table. The column names are not specified by the SQL
> standard and different database systems do it differently, so it's usually
> better to override the default names with a table alias list, like this:
>
> => SELECT * FROM (VALUES (1, 'one'), (2, 'two'), (3, 'three')) AS t 
> (num,letter);
>  num | letter
> -----+--------
>    1 | one
>    2 | two
>    3 | three
> (3 rows)
>
> -------------
>
> Peter
>
>
>
> On Thu, Jan 18, 2018 at 10:58 AM, Richard Hipp <d...@sqlite.org> wrote:
>
>> On 1/18/18, Szyk Cech <szykc...@spoko.pl> wrote:
>> > Hi
>> >
>> > My concern is about a Primary Key in two columns (integer values) which
>> > I want type explicitly in my query (like in example "Not works"). My
>> > example only shows problem and it is not real case (however database is
>> > real).
>> >
>> > Not works:
>> >
>> > select * from card where (statNumber, question) in ((2211, 'psuć się'),
>> > (2542, 'kontynuować'), (1449, 'wymrzeć'))
>>
>> Try it this way:
>>
>>   SELECT * FROM card WHERE (statNumber,question) IN
>>     (VALUES(2211,'psuc sei'),(2542,'kontynuowac'), (1449,'wymrzec'));
>>
>> I am open to enhancing the syntax here, but not right now because we
>> are trying to get the 3.22.0 release out - this would need to be
>> during the next cycle.  Also, I'll need to check to see what
>> PostgreSQL does first, and emulate them.
>>
>> >
>> > Works:
>> >
>> > select * from card where (statNumber, question) in (select statNumber,
>> > question from card)
>> >
>> > Why?
>> >
>> > thanks and best regards
>> >
>> > Szyk Cech
>> >
>> > _______________________________________________
>> > sqlite-users mailing list
>> > sqlite-users@mailinglists.sqlite.org
>> > http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>> >
>>
>>
>> --
>> D. Richard Hipp
>> d...@sqlite.org
>> _______________________________________________
>> sqlite-users mailing list
>> sqlite-users@mailinglists.sqlite.org
>> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>>
>
>
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to