row-value-expression

Using tuples in SQL “IN” clause

拟墨画扇 提交于 2019-12-28 01:47:30
问题 I have a table containing the fields group_id and group_type and I want to query the table for all the records having any tuple ( group id , group type ) from a list of tuples. For example, I want to be able to do something like: SELECT * FROM mytable WHERE (group_id, group_type) IN (("1234-567", 2), ("4321-765", 3), ("1111-222", 5)) A very similar question is already asked at: using tuples in sql in clause , but the solution proposed there presumes the tuple list is to be fetched from

Using IN with sets of tuples in SQL (SQLite3)

∥☆過路亽.° 提交于 2019-12-21 12:23:51
问题 I have the following table in a SQLite3 database: CREATE TABLE overlap_results ( neighbors_of_annotation varchar(20), other_annotation varchar(20), set1_size INTEGER, set2_size INTEGER, jaccard REAL, p_value REAL, bh_corrected_p_value REAL, PRIMARY KEY (neighbors_of_annotation, other_annotation) ); I would like to perform the following query: SELECT * FROM overlap_results WHERE (neighbors_of_annotation, other_annotation) IN (('16070', '8150'), ('16070', '44697')); That is, I have a couple of

How to compare groups of tuples in sql

非 Y 不嫁゛ 提交于 2019-12-10 11:57:00
问题 How to compare groups of tuples in sql: consider the following example: TABLE T1 -------- GROUP VALUE ----- ----- A FOO A BAR X HHH X ZOO TABLE T2 -------- GROUP VALUE ----- ----- B ZOO C FOO C BAR I want to write an sql query which compares the groups of values in both tables and reports the differences. In the illustrated example, the group in table a: ((A,FOO),(A,BAR)) is the same as the group ((C,FOO),(C,BAR)) even though the group name is different. What counts is that the contents of

Using IN with sets of tuples in SQL (SQLite3)

十年热恋 提交于 2019-12-04 05:26:13
I have the following table in a SQLite3 database: CREATE TABLE overlap_results ( neighbors_of_annotation varchar(20), other_annotation varchar(20), set1_size INTEGER, set2_size INTEGER, jaccard REAL, p_value REAL, bh_corrected_p_value REAL, PRIMARY KEY (neighbors_of_annotation, other_annotation) ); I would like to perform the following query: SELECT * FROM overlap_results WHERE (neighbors_of_annotation, other_annotation) IN (('16070', '8150'), ('16070', '44697')); That is, I have a couple of tuples of annotation IDs, and I'd like to fetch records for each of those tuples. The sqlite3 prompt

SQL: tuple comparison

送分小仙女□ 提交于 2019-11-30 07:25:56
问题 In my current application, I need to be able to do this type of query: SELECT MIN((colA, colB, colC)) FROM mytable WHERE (colA, colB, colC) BETWEEN (200, 'B', 'C') AND (1000, 'E', 'F') and get the answer of (333, 'B', 'B') , given this data: +------+------+------+ | colA | colB | colC | +------+------+------+ | 99 | A | A | | 200 | A | Z | | 200 | B | B | | 333 | B | B | | 333 | C | D | | 333 | C | E | | 333 | D | C | | 1000 | E | G | | 1000 | F | A | +------+------+------+ What is the most

SQL: tuple comparison

与世无争的帅哥 提交于 2019-11-29 03:38:28
In my current application, I need to be able to do this type of query: SELECT MIN((colA, colB, colC)) FROM mytable WHERE (colA, colB, colC) BETWEEN (200, 'B', 'C') AND (1000, 'E', 'F') and get the answer of (333, 'B', 'B') , given this data: +------+------+------+ | colA | colB | colC | +------+------+------+ | 99 | A | A | | 200 | A | Z | | 200 | B | B | | 333 | B | B | | 333 | C | D | | 333 | C | E | | 333 | D | C | | 1000 | E | G | | 1000 | F | A | +------+------+------+ What is the most efficient way to accomplish this in real SQL? Please keep in mind that this is a toy example, and that

using tuples in sql in clause

折月煮酒 提交于 2019-11-27 21:27:25
Given a database like this: BEGIN TRANSACTION; CREATE TABLE aTable ( a STRING, b STRING); INSERT INTO aTable VALUES('one','two'); INSERT INTO aTable VALUES('one','three'); CREATE TABLE anotherTable ( a STRING, b STRING); INSERT INTO anotherTable VALUES('one','three'); INSERT INTO anotherTable VALUES('two','three'); COMMIT; I would like to do something along the lines of SELECT a,b FROM aTable WHERE (aTable.a,aTable.b) IN (SELECT anotherTable.a,anotherTable.b FROM anotherTable); To get the answer 'one','three', but I'm getting "near ",": syntax error" Is this possible in any flavour of SQL? (I

using tuples in sql in clause

烈酒焚心 提交于 2019-11-27 04:31:54
问题 Given a database like this: BEGIN TRANSACTION; CREATE TABLE aTable ( a STRING, b STRING); INSERT INTO aTable VALUES('one','two'); INSERT INTO aTable VALUES('one','three'); CREATE TABLE anotherTable ( a STRING, b STRING); INSERT INTO anotherTable VALUES('one','three'); INSERT INTO anotherTable VALUES('two','three'); COMMIT; I would like to do something along the lines of SELECT a,b FROM aTable WHERE (aTable.a,aTable.b) IN (SELECT anotherTable.a,anotherTable.b FROM anotherTable); To get the