SELECT Subquery


Subquery로 데이터를 조회

Subquery로 데이터를 조회합니다.

테스트 데이터 입력

Example

명령>mset id_0001 myname1 id_0002 myname2 id_0003 myname3 id_0004 myname4 id_0005 myname5
결과>OK
명령>rpush id_list id_0001 id_0002 id_0003 id_0004 id_0005
결과>5
명령>sadd id_set id_0001 id_0002 id_0003 id_0004 id_0005
결과>5
명령>zadd id_zset 10 id_0001 20 id_0002 30 id_0003 40 id_0004 50 id_0005
결과>5

SELECT * FROM STRING.ID* WHERE IN (SELECT ...)

Main query String - Subquery List

Example

명령>select * from string.id* where key in (select value from list.id_list);
결과> 0) key|value
1) id_0001|myname1
2) id_0002|myname2
3) id_0003|myname3
4) id_0004|myname4
5) id_0005|myname5

Main query String - Subquery Set

Example

명령>select * from string.id* where key in (select value from set.id_set);
결과> 0) key|value
1) id_0001|myname1
2) id_0002|myname2
3) id_0003|myname3
4) id_0004|myname4
5) id_0005|myname5

Main query String - Subquery ZSet

Example

명령>select * from string.id* where key in (select value from zset.id_zset);
결과> 0) key|value
1) id_0001|myname1
2) id_0002|myname2
3) id_0003|myname3
4) id_0004|myname4
5) id_0005|myname5

Main query String - Subquery Hash

Example

명령>select * from string.id* where value in (select key from hash.myname*);
결과> 0) key|value
1) id_0001|myname1
2) id_0002|myname2
3) id_0003|myname3
4) id_0004|myname4
5) id_0005|myname5

SELECT * FROM LIST.ID_LIST WHERE IN (SELECT ...)

Main query List - Subquery String

Example

명령>select * from list.id_list where value in (select key from string.id_00*);
결과> 0) key|value
1) id_list|id_0001
2) id_list|id_0002
3) id_list|id_0003
4) id_list|id_0004
5) id_list|id_0005

Main query Set - Subquery String

Example

명령>select * from set.id_set where value in (select key from string.id_00*);
결과> 0) key|value
1) id_set|id_0004
2) id_set|id_0003
3) id_set|id_0002
4) id_set|id_0001
5) id_set|id_0005

Main query ZSet - Subquery String

Example

명령>select * from zset.id_zset where value in (select key from string.id_00*);
결과> 0) key|score|value
1) id_zset|10.0|id_0001
2) id_zset|20.0|id_0002
3) id_zset|30.0|id_0003
4) id_zset|40.0|id_0004
5) id_zset|50.0|id_0005

Main query Hash - Subquery String

Example

명령>select * from hash.myname* where key in (select value from string.id_00*);
결과> 0) key|name|age|birthday|city|hobby
1) myname1|kim|25|1995-01-01|Seoul|(nil)
2) myname2|kang|30|1990-01-01|Daejeon|(nil)
3) myname3|park|20|2000-01-01|Seoul|ski,bike
4) myname4|choe|30|1990-01-01|Daejeon|(nil)
5) myname5|lee|35|1985-01-01|Busan|(nil)

<< Select Stream Select Subquery Select Union >>

조회수 :

Email 답글이 올라오면 이메일로 알려드리겠습니다.