88 :note for grouped queries: |
88 :note for grouped queries: |
89 For grouped queries (e.g. using function `GROUPBY`), all the selected |
89 For grouped queries (e.g. using function `GROUPBY`), all the selected |
90 variables must be grouped or aggregated. |
90 variables must be grouped or aggregated. |
91 |
91 |
92 Examples - search |
92 Examples - search |
93 ````````````````` |
93 ~~~~~~~~~~~~~~~~~ |
94 :: |
94 :: |
95 |
95 |
96 Any X WHERE X eid 53 |
96 Any X WHERE X eid 53 |
97 Personne X |
97 Personne X |
98 Personne X WHERE X travaille_pour S, S nom "logilab" |
98 Personne X WHERE X travaille_pour S, S nom "logilab" |
99 Any E,COUNT(X) GROUPBY E ORDERBY EN WHERE X is E, E name EN |
99 Any E,COUNT(X) GROUPBY E ORDERBY EN WHERE X is E, E name EN |
100 Any E,COUNT(X) GROUPBY E ORDERBY 2 WHERE X is E |
100 Any E,COUNT(X) GROUPBY E ORDERBY 2 WHERE X is E |
101 |
101 |
102 |
102 |
103 Advanced features |
103 Advanced features |
104 ````````````````` |
104 ~~~~~~~~~~~~~~~~~ |
105 * Aggregate functions: `COUNT`, `MIN`, `MAX`, `SUM`. |
105 * Aggregate functions: `COUNT`, `MIN`, `MAX`, `SUM`. |
106 * String functions:`UPPER`, `LOWER`. |
106 * String functions:`UPPER`, `LOWER`. |
107 * Optional relations: |
107 * Optional relations: |
108 |
108 |
109 * They allow to select entities related to others or not. |
109 * They allow to select entities related to others or not. |
118 - All the cards and the project they document otherwise :: |
118 - All the cards and the project they document otherwise :: |
119 |
119 |
120 Any C,P WHERE C is Card, P? documented_by C |
120 Any C,P WHERE C is Card, P? documented_by C |
121 |
121 |
122 Negation |
122 Negation |
123 ```````` |
123 ~~~~~~~~ |
124 * A query such as `Document X WHERE NOT X owned_by U` is equivalent to |
124 * A query such as `Document X WHERE NOT X owned_by U` is equivalent to |
125 "the documents which do not have relation `owned_by`". |
125 "the documents which do not have relation `owned_by`". |
126 * Whereas the query `Document X WHERE NOT X owned_by U, U login "syt"` |
126 * Whereas the query `Document X WHERE NOT X owned_by U, U login "syt"` |
127 is equivalent to "the documents which do not have relation `owned_by` |
127 is equivalent to "the documents which do not have relation `owned_by` |
128 with the user syt". They could have a relation with other users. |
128 with the user syt". They could have a relation with other users. |
129 |
129 |
130 |
130 |
131 Identity |
131 Identity |
132 ```````` |
132 ~~~~~~~~ |
133 |
133 |
134 We could use the special relation `identity` in a query in order to add a |
134 We could use the special relation `identity` in a query in order to add a |
135 condition of identity between two variables. This is equivalent to ``is`` |
135 condition of identity between two variables. This is equivalent to ``is`` |
136 in Python. |
136 in Python. |
137 |
137 |
152 |
152 |
153 Be careful, if a condition is specified, the insertion is done *for each result |
153 Be careful, if a condition is specified, the insertion is done *for each result |
154 returned by the condition*. |
154 returned by the condition*. |
155 |
155 |
156 Examples - insertion |
156 Examples - insertion |
157 ````````````````````` |
157 ~~~~~~~~~~~~~~~~~~~~~ |
158 * Insertion of a new person named 'bidule':: |
158 * Insertion of a new person named 'bidule':: |
159 |
159 |
160 INSERT Person X: X name 'bidule' |
160 INSERT Person X: X name 'bidule' |
161 |
161 |
162 * Insertion of a new person named 'bidule', another named |
162 * Insertion of a new person named 'bidule', another named |
177 |
177 |
178 Be careful, if a condition is specified, the update is done *for each result |
178 Be careful, if a condition is specified, the update is done *for each result |
179 returned by the condition*. |
179 returned by the condition*. |
180 |
180 |
181 Examples - update |
181 Examples - update |
182 ````````````````` |
182 ~~~~~~~~~~~~~~~~~ |
183 * Renaming of the person named 'bidule' to 'toto', with change on the first name:: |
183 * Renaming of the person named 'bidule' to 'toto', with change on the first name:: |
184 |
184 |
185 SET X name 'toto', X firstname 'original' WHERE X is 'Person', X name 'bidule' |
185 SET X name 'toto', X firstname 'original' WHERE X is 'Person', X name 'bidule' |
186 |
186 |
187 * Insertion of a relation of type 'know' between two objects linked with the relation |
187 * Insertion of a relation of type 'know' between two objects linked with the relation |
198 Be careful, if a condition is specified, the deletion is done *for each result |
198 Be careful, if a condition is specified, the deletion is done *for each result |
199 returned by the condition*. |
199 returned by the condition*. |
200 |
200 |
201 |
201 |
202 Examples |
202 Examples |
203 ```````` |
203 ~~~~~~~~ |
204 * Deletion of the person named 'toto':: |
204 * Deletion of the person named 'toto':: |
205 |
205 |
206 DELETE Person X WHERE X name 'toto' |
206 DELETE Person X WHERE X name 'toto' |
207 |
207 |
208 * Deletion of all the relations of type 'friend' linked to the person named |
208 * Deletion of all the relations of type 'friend' linked to the person named |