using tuples in sql in clause

前端 未结 3 2027
夕颜
夕颜 2020-12-05 20:42

Given a database like this:

BEGIN TRANSACTION;
CREATE TABLE aTable (
a STRING,
b STRING);
INSERT INTO aTable VALUES(\'one\',\'two\');
INSERT INTO aTable VALU         


        
3条回答
  •  执念已碎
    2020-12-05 20:58

    Another alternative is to use concatenation to make your 2-tuple into a single field :

    SELECT a,b FROM aTable
    WHERE (aTable.a||'-'||aTable.b) IN
    (SELECT (anotherTable.a || '-' || anotherTable.b FROM anotherTable);
    

    ...just be aware that bad things can happen if a or b contain the delimiter '-'

提交回复
热议问题