반응형

/*******************************************************************************************************************
-- Title : [Cb5.0] SELECT ~ FROM ~ WHERE 기본 구문
-- Reference : couchbase.com
-- Key word : select from where select raw select distinct raw use keys n1ql
*******************************************************************************************************************/

■ Scripts

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
-- SELECT vs. SELECT RAW
SELECT {"a":1"b":2};
SELECT RAW {"a":1"b":2};
 

-- SELECT RAW vs. SELECT DISTINCT RAW
SELECT city 
FROM `travel-sample` 
WHERE type="airport"
ORDER BY city LIMIT 5;
 
SELECT RAW city 
FROM `travel-sample`
WHERE type="airport"
ORDER BY city LIMIT 5;
 
SELECT DISTINCT RAW city 
FROM `travel-sample`
WHERE type="airport" 
ORDER BY city LIMIT 5;
 
SELECT DISTINCT city 
FROM `travel-sample` 
WHERE type="airport" 
ORDER BY city LIMIT 5;
 

-- LIMIT
SELECT * 
FROM `beer-sample` 
LIMIT 2;
 
SELECT city, code, geo, name 
FROM `beer-sample` 
LIMIT 5;
 

-- WHERE
SELECT * 
FROM `beer-sample` 
WHERE name = "21A IPA";
 

-- NULL
SELECT name, city, coucntry, geo 
FROM `beer-sample`
WHERE geo IS NOT NULL
LIMIT 100;
 

-- WHERE 계층 조건
SELECT * FROM `beer-sample`
WHERE geo.accuracy = "APPROXIMATE"
LIMIT 5;
 

-- SELECT 계층 조회
SELECT name, geo.accuracy, geo.lat 
FROM `beer-sample`
WHERE geo IS NOT NULL
LIMIT 100;
 
 
-- 리스트 조회
SELECT meta().id, email, city, phone, reviews[0].ratings 
FROM `travel-sample` 
WHERE type="hotel" 
LIMIT 5;
 
 
-- 메타 정보 출력
SELECT meta().*
FROM `beer-sample` 
LIMIT 5;
 
SELECT meta().id, meta().flags, meta().expiration, meta().cas
FROM `beer-sample` 
LIMIT 5;
 
 
-- USE KEYS
SELECT *
FROM `beer-sample`
WHERE meta().id = "21st_amendment_brewery_cafe";
 
SELECT *
FROM `beer-sample`
USE KEYS "21st_amendment_brewery_cafe";
cs


반응형

+ Recent posts