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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
|
<?xml version="1.0" encoding="UTF-8"?>
<helpdocument version="1.0">
<!--
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
-->
<meta>
<topic id="textsharedexplorerdatabase02010100xml" indexer="include" status="PUBLISH">
<title id="tit" xml-lang="en-US">Query Design</title>
<filename>/text/sdatabase/02010100.xhp</filename>
</topic>
</meta>
<body>
<bookmark xml-lang="en-US" branch="index" id="bm_id3153323">
<bookmark_value>views; creating database views (Base)</bookmark_value>
<bookmark_value>queries; creating in design view (Base)</bookmark_value>
<bookmark_value>designing; queries (Base)</bookmark_value>
<bookmark_value>design view; queries/views (Base)</bookmark_value>
<bookmark_value>joining;tables (Base)</bookmark_value>
<bookmark_value>tables in databases; joining for queries (Base)</bookmark_value>
<bookmark_value>queries; joining tables (Base)</bookmark_value>
<bookmark_value>tables in databases; relations (Base)</bookmark_value>
<bookmark_value>relations; joining tables (Base)</bookmark_value>
<bookmark_value>queries; deleting table links (Base)</bookmark_value>
<bookmark_value>criteria of query design (Base)</bookmark_value>
<bookmark_value>queries; formulating filter conditions (Base)</bookmark_value>
<bookmark_value>filter conditions;in queries (Base)</bookmark_value>
<bookmark_value>parameters; queries (Base)</bookmark_value>
<bookmark_value>queries; parameter queries (Base)</bookmark_value>
<bookmark_value>SQL; queries (Base)</bookmark_value>
<bookmark_value>native SQL (Base)</bookmark_value>
</bookmark>
<comment>mw added "(Base)" to all entries</comment>
<paragraph id="par_id3153323" role="paragraph" localize="false" xml-lang="en-US"/>
<h1 id="hd_id3153394"><link href="text/sdatabase/02010100.xhp" name="Query Design">Query Design</link></h1>
<paragraph id="par_id3156411" role="paragraph" xml-lang="en-US"><ahelp hid=".">The <emph>Query Design View </emph>allows you to create and edit a database query.</ahelp></paragraph>
<section id="howtoget">
<embed href="text/shared/00/00000450.xhp#entwab"/>
</section>
<note id="par_id7024140">Most databases use queries to filter or to sort database tables to display records on your computer. Views offer the same functionality as queries, but on the server side. If your database is on a server that supports views, you can use views to filter the records on the server to speed up the display time.</note>
<note id="par_id3159176">Selecting the <emph>Create View</emph> command from the <emph>Tables</emph> tab page of a database document, you see the <emph>View Design</emph> window that resembles the <emph>Query Design</emph> window described here.</note>
<paragraph id="par_id8307138" role="paragraph" xml-lang="en-US">The Query Design window layout is stored with a created query, but cannot be stored with a created view.</paragraph>
<h2 id="hd_id3149233">The Design View</h2>
<paragraph id="par_id3145673" role="paragraph" xml-lang="en-US">To create a query, click the <emph>Queries</emph> icon in a database document, then click <emph>Create Query in Design View</emph>.</paragraph>
<paragraph id="par_id3150255" role="paragraph" xml-lang="en-US">The lower pane of the Design View is where you define the query. To define a query, specify the database field names to include and the criteria for displaying the fields. To rearrange the columns in the lower pane of the Design View, drag a column header to a new location, or select the column and press <switchinline select="sys"><caseinline select="MAC">Command
</caseinline><defaultinline>Ctrl</defaultinline></switchinline>+arrow key.</paragraph>
<paragraph id="par_id3152474" role="paragraph" xml-lang="en-US">In the top of the query Design View window, the <link href="text/shared/main0214.xhp" name="icons">icons</link> of the <emph>Query Design</emph> Bar and the <emph>Design</emph> bar are displayed.</paragraph>
<paragraph id="par_id3147559" role="paragraph" xml-lang="en-US">If you want to test a query, double-click the query name in the database document. The query result is displayed in a table similar to the Data Source View. Note: the table displayed is only temporary.</paragraph>
<h3 id="hd_id8226264">Keys in Query Design View</h3>
<table id="tbl_id1880855">
<tablerow>
<tablecell>
<paragraph id="par_id2341074" role="tablehead" xml-lang="en-US">Key</paragraph>
</tablecell>
<tablecell>
<paragraph id="par_id4384289" role="tablehead" xml-lang="en-US">Function</paragraph>
</tablecell>
</tablerow>
<tablerow>
<tablecell>
<paragraph id="par_id5839106" role="tablecontent" xml-lang="en-US">F4</paragraph>
</tablecell>
<tablecell>
<paragraph id="par_id8554338" role="tablecontent" xml-lang="en-US">Preview</paragraph>
</tablecell>
</tablerow>
<tablerow>
<tablecell>
<paragraph id="par_id1254921" role="tablecontent" xml-lang="en-US">F5</paragraph>
</tablecell>
<tablecell>
<paragraph id="par_id7636646" role="tablecontent" xml-lang="en-US">Run Query</paragraph>
</tablecell>
</tablerow>
<tablerow>
<tablecell>
<paragraph id="par_id8579363" role="tablecontent" xml-lang="en-US">F7</paragraph>
</tablecell>
<tablecell>
<paragraph id="par_id3227942" role="tablecontent" xml-lang="en-US">Add Table or Query</paragraph>
</tablecell>
</tablerow>
</table>
<h2 id="hd_id3154939">Browse</h2>
<paragraph id="par_id3148799" role="paragraph" xml-lang="en-US">When you open the query design for the first time, you see a dialog in which you must first select the table or query that will be the basis for your new query.</paragraph>
<bookmark xml-lang="en-US" branch="hid/DBACCESS_HID_CTL_QRYDGNTAB" id="bm_id3150767" localize="false"/>
<paragraph id="par_id3144762" role="paragraph" xml-lang="en-US"><ahelp hid="HID_CTL_QRYDGNTAB">Double-click fields to add them to the query. Drag-and-drop to define relations.</ahelp></paragraph>
<note id="par_id3157894">While designing a query, you cannot modify the selected tables.</note>
<h3 id="hd_id3149562">Remove tables</h3>
<paragraph id="par_id3150685" role="paragraph" xml-lang="en-US">To remove the table from Design View, click the upper border of the table window and display the context menu. You can use the <emph>Delete</emph> command to remove the table from the Design View. Another option is to press the Delete key.</paragraph>
<section id="change_display">
<h3 id="hd_id3150012">Move table and modify table size</h3>
<paragraph id="par_id3146922" role="paragraph" xml-lang="en-US">You can resize and arrange the tables according to your preferences. To move tables, drag the upper border to the desired position. Enlarge or reduce the size in which the table is displayed by positioning the mouse cursor on a border or on a corner and dragging the table until it is the desired size.</paragraph>
</section>
<h2 id="hd_id3145365">Table Relations</h2>
<paragraph id="par_id3154145" role="paragraph" xml-lang="en-US">If there are data relations between a field name in one table and a field name in another table, you can use these relations for your query.</paragraph>
<paragraph id="par_id3152577" role="paragraph" xml-lang="en-US">If, for example, you have a spreadsheet for articles identified by an article number, and a spreadsheet for customers in which you record all articles that a customer orders using the corresponding article numbers, then there is a relationship between the two "article number" data fields. If you now want to create a query that returns all articles that a customer has ordered, you must retrieve data from two spreadsheets. To do this, you must inform $[officename] about the relationship which exists between the data in the two spreadsheets.</paragraph>
<paragraph id="par_id3155302" role="paragraph" xml-lang="en-US">To do this, click a field name in a table (for example, the field name "Item-Number" from the Customer table), hold down the mouse button and then drag the field name to the field name of the other table ("Item-Number" from the Item table). When you release the mouse button, a line connecting the two fields between the two table windows appears. The corresponding condition that the content of the two field names must be identical is entered in the resulting SQL query.</paragraph>
<paragraph id="par_id3153876" role="paragraph" xml-lang="en-US">The creation of a query that is based on several related sheets is only possible if you use $[officename] as the interface for a relational database.</paragraph>
<note id="par_id3145646">You cannot access tables from different databases in a query. Queries involving multiple tables can only be created within one database.</note>
<h3 id="hd_id3153279">Specifying the relation type</h3>
<paragraph id="par_id3154791" role="paragraph" xml-lang="en-US">If you double-click on the line connecting two linked fields or call the menu command <emph>Insert - New Relation</emph>, you can specify the type of relation in the <link href="text/sdatabase/02010101.xhp" name="Relations"><emph>Relations</emph></link> dialog.</paragraph>
<bookmark xml-lang="en-US" branch="hid/DBACCESS_HID_QUERY_EDIT_JOINCONNECTION" id="bm_id3145253" localize="false"/>
<paragraph id="par_id3150094" role="paragraph" xml-lang="en-US"><ahelp hid="HID_QUERY_EDIT_JOINCONNECTION" visibility="hidden">Edit Join Properties.</ahelp> Alternatively, press Tab until the line is selected, then press Shift+F10 to display the context menu and there choose the command <emph>Edit</emph>. Some databases support only a subset of the possible join types.</paragraph>
<h3 id="hd_id3155851">Deleting relations</h3>
<paragraph id="par_id3156178" role="paragraph" xml-lang="en-US">To delete a relation between two tables, click the connection line and then press the Delete key.</paragraph>
<paragraph id="par_id3150715" role="paragraph" xml-lang="en-US">Alternatively, delete the respective entries in <emph>Fields involved </emph>in the <emph>Relations</emph> dialog. Or press Tab until the connecting vector is displayed highlighted, then press Shift+F10 to open the context menu and select <emph>Delete </emph>command.</paragraph>
<bookmark xml-lang="en-US" branch="hid/DBACCESS_HID_CTL_QRYDGNCRIT" id="bm_id3152972" localize="false"/>
<h2 id="hd_id3151208">Defining the query</h2>
<paragraph id="par_id3158416" role="paragraph" xml-lang="en-US"><ahelp hid="HID_CTL_QRYDGNCRIT">Select conditions to define the query.</ahelp> Each column of the design table accepts a data field for the query. The conditions in one row are linked with a Boolean AND.</paragraph>
<h3 id="hd_id3154161">Specifying field names</h3>
<paragraph id="par_id3146791" role="paragraph" xml-lang="en-US">First, select all field names from the tables that you want to add to the query. You can do this either by drag-and-drop or by double-clicking a field name in the table window. With the drag-and-drop method, use the mouse to drag a field name from the table window into the lower area of the query design window. As you do this, you can decide which column in the query design window will receive the selected field. A field name can also be selected by double-clicking. It will then be added to the next free column in the query design window.</paragraph>
<h3 id="hd_id3150750">Deleting field names</h3>
<paragraph id="par_id3154479" role="paragraph" xml-lang="en-US">To remove a field name from the query, click the column header of the field and choose the <emph>Delete</emph> command on the context menu for the column.</paragraph>
<h3 id="hd_id3155764">Saving the query</h3>
<paragraph id="par_id3148481" role="paragraph" xml-lang="en-US">Use the <emph>Save</emph> icon on the Standard toolbar to save the query. You will see a dialog that asks you to enter a name for the query. If the database supports schemas, you can also enter a schema name.</paragraph>
<bookmark xml-lang="en-US" branch="hid/dbaccess/ui/savedialog/schema" id="bm_id3156378" localize="false"/>
<h4 id="hd_id3154362">Schema</h4>
<paragraph id="par_id3154754" role="paragraph" xml-lang="en-US"><ahelp hid="dbaccess/ui/savedialog/schema">Enter the name of the schema that is assigned to the query or table view.</ahelp></paragraph>
<bookmark xml-lang="en-US" branch="hid/dbaccess/ui/savedialog/title" id="bm_id3147340" localize="false"/>
<h4 id="hd_id3156717">Query name or table view name</h4>
<paragraph id="par_id3154253" role="paragraph" xml-lang="en-US"><ahelp hid="dbaccess/ui/savedialog/title">Enter the name of the query or table view.</ahelp></paragraph>
<h3 id="hd_id3163805">Filtering data</h3>
<paragraph id="par_id3154964" role="paragraph" xml-lang="en-US">To filter data for the query, set the desired criteria in the lower area of the query design window. The following options are available:</paragraph>
<bookmark xml-lang="en-US" branch="hid/DBACCESS_HID_QRYDGN_ROW_FIELD" id="bm_id3148536" localize="false"/>
<h4 id="hd_id3146916">Field</h4>
<paragraph id="par_id3156372" role="paragraph" xml-lang="en-US"><ahelp hid="HID_QRYDGN_ROW_FIELD">Enter the name of the data field that is referred to in the Query. All settings made in the filter option rows refer to this field.</ahelp> If you activate a cell here with a mouse click you'll see an arrow button, which enables you to select a field. The "Table name.*" option selects all data fields with the effect that the specified criteria will be applied to all table fields.</paragraph>
<bookmark xml-lang="en-US" branch="hid/DBACCESS_HID_QRYDGN_ROW_ALIAS" id="bm_id3154702" localize="false"/>
<h4 id="hd_id3145150">Alias</h4>
<paragraph id="par_id3146315" role="paragraph" xml-lang="en-US"><ahelp hid="HID_QRYDGN_ROW_ALIAS">Specifies an alias. This alias will be listed in the query instead of the field name. This makes it possible to use user-defined column labels.</ahelp> For example, if the data field is named PtNo and, instead of that name, you would like to have PartNum appear in the query, enter PartNum as the alias.</paragraph>
<paragraph id="par_id3155959" role="paragraph" xml-lang="en-US">In a SQL statement, aliases are defined as follows:</paragraph>
<paragraph id="par_id3149922" role="code" xml-lang="en-US">SELECT column AS alias FROM table.</paragraph>
<paragraph id="par_id3159335" role="paragraph" xml-lang="en-US">For example:</paragraph>
<sqlcode>
<paragraph id="par_id3148478" role="sqlcode" localize="false" xml-lang="en-US">SELECT "PtNo" AS "PartNum" FROM "Parts"</paragraph>
</sqlcode>
<bookmark xml-lang="en-US" branch="hid/DBACCESS_HID_QRYDGN_ROW_TABLE" id="bm_id3154665" localize="false"/>
<h4 id="hd_id3148485">Table</h4>
<paragraph id="par_id3163665" role="paragraph" xml-lang="en-US"><ahelp hid="HID_QRYDGN_ROW_TABLE">The corresponding database table of the selected data field is listed here.</ahelp> If you activate this cell with a mouse click, an arrow will appear which enables you to select a different table for the current query.</paragraph>
<bookmark xml-lang="en-US" branch="hid/DBACCESS_HID_QRYDGN_ROW_ORDER" id="bm_id3154202" localize="false"/>
<h4 id="hd_id3154207">Sort</h4>
<paragraph id="par_id3150979" role="paragraph" xml-lang="en-US"><ahelp hid="HID_QRYDGN_ROW_ORDER">If you click on this cell, you can choose a sort option: ascending, descending and unsorted.</ahelp> Text fields will be sorted alphabetically and numerical fields numerically. For most databases, administrators can set the sorting options at the database level.</paragraph>
<bookmark xml-lang="en-US" branch="hid/DBACCESS_HID_QRYDGN_ROW_VISIBLE" id="bm_id3149334" localize="false"/>
<h4 id="hd_id3150384">Visible</h4>
<paragraph id="par_id3146133" role="paragraph" xml-lang="en-US"><ahelp hid="HID_QRYDGN_ROW_VISIBLE">If you mark the <emph>Visible</emph> property for a data field, that field will be visibly displayed in the resulting query</ahelp>. If you are only using a data field to formulate a condition or make a calculation, you do not necessarily need to display it.</paragraph>
<bookmark xml-lang="en-US" branch="hid/DBACCESS_HID_QRYDGN_ROW_CRIT" id="bm_id3147130" localize="false"/>
<h4 id="hd_id3154714">Criteria</h4>
<paragraph id="par_id3145134" role="paragraph" xml-lang="en-US"><ahelp hid="HID_QRYDGN_ROW_CRIT">Specifies a first criteria by which the content of the data field is to be filtered.</ahelp></paragraph>
<h4 id="hd_id3152477">or</h4>
<paragraph id="par_id3154585" role="paragraph" xml-lang="en-US">Here you can enter one additional filter criterion for each line. Multiple criteria in a single column will be interpreted as boolean OR.</paragraph>
<paragraph id="par_id3148800" role="paragraph" xml-lang="en-US">You can also use the context menu of the line headers in the lower area of the query design window to insert a filter based on a function:</paragraph>
<bookmark xml-lang="en-US" branch="hid/DBACCESS_HID_QRYDGN_ROW_FUNCTION" id="bm_id3153275" localize="false"/>
<h3 id="hd_id3148419">Functions</h3>
<paragraph id="par_id3153233" role="paragraph" xml-lang="en-US"><ahelp hid="HID_QRYDGN_ROW_FUNCTION" visibility="hidden">Select a function to run in the query.</ahelp> The functions which are available here depend on those provided by the database engine. </paragraph>
<paragraph id="par_id8760818" role="paragraph" xml-lang="en-US">If you are working with the embedded HSQL database, the list box in the <emph>Function</emph> row offers you the following options:</paragraph>
<table id="tbl_id3148461">
<tablerow>
<tablecell>
<paragraph id="par_id3150307" role="tablehead" xml-lang="en-US">Option</paragraph>
</tablecell>
<tablecell>
<paragraph id="par_id3166430" role="tablehead" xml-lang="en-US" localize="false">SQL</paragraph>
</tablecell>
<tablecell>
<paragraph id="par_id3152993" role="tablehead" xml-lang="en-US">Effect</paragraph>
</tablecell>
</tablerow>
<tablerow>
<tablecell>
<paragraph id="par_id3155377" role="tablecontent" xml-lang="en-US">No function</paragraph>
</tablecell>
<tablecell>
</tablecell>
<tablecell>
<paragraph id="par_id3155533" role="tablecontent" xml-lang="en-US">No function will be executed.</paragraph>
</tablecell>
</tablerow>
<tablerow>
<tablecell>
<paragraph id="par_id3166420" role="tablecontent" xml-lang="en-US">Average</paragraph>
</tablecell>
<tablecell>
<paragraph id="par_id3145268" role="tablecontent" xml-lang="en-US" localize="false">AVG</paragraph>
</tablecell>
<tablecell>
<paragraph id="par_id3154486" role="tablecontent" xml-lang="en-US">Calculates the arithmetic mean of a field.</paragraph>
</tablecell>
</tablerow>
<tablerow>
<tablecell>
<paragraph id="par_id3149979" role="tablecontent" xml-lang="en-US">Count</paragraph>
</tablecell>
<tablecell>
<paragraph id="par_id3154260" role="tablecontent" xml-lang="en-US" localize="false">COUNT</paragraph>
</tablecell>
<tablecell>
<paragraph id="par_id3155810" role="tablecontent" xml-lang="en-US">Determines the number of records in the table. Empty fields can either be counted (a) or excluded (b).</paragraph>
<paragraph id="par_id3151333" role="tablecontent" xml-lang="en-US">a) COUNT(*): Passing an asterisk as the argument counts all records in the table.</paragraph>
<paragraph id="par_id3152889" role="tablecontent" xml-lang="en-US">b) COUNT(column): Passing a field name as an argument counts only the records in which the specified field contains a value. Records in which the field has a Null value (i.e. contains no textual or numeric value) will not be counted.</paragraph>
</tablecell>
</tablerow>
<tablerow>
<tablecell>
<paragraph id="par_id3153067" role="tablecontent" xml-lang="en-US">Maximum</paragraph>
</tablecell>
<tablecell>
<paragraph id="par_id3148840" role="tablecontent" xml-lang="en-US" localize="false">MAX</paragraph>
</tablecell>
<tablecell>
<paragraph id="par_id3159221" role="tablecontent" xml-lang="en-US">Determines the highest value of a record for that field.</paragraph>
</tablecell>
</tablerow>
<tablerow>
<tablecell>
<paragraph id="par_id3146866" role="tablecontent" xml-lang="en-US">Minimum</paragraph>
</tablecell>
<tablecell>
<paragraph id="par_id3148604" role="tablecontent" xml-lang="en-US" localize="false">MIN</paragraph>
</tablecell>
<tablecell>
<paragraph id="par_id3157982" role="tablecontent" xml-lang="en-US">Determines the lowest value of a record for that field.</paragraph>
</tablecell>
</tablerow>
<tablerow>
<tablecell>
<paragraph id="par_id3154828" role="tablecontent" xml-lang="en-US">Sum</paragraph>
</tablecell>
<tablecell>
<paragraph id="par_id3147070" role="tablecontent" xml-lang="en-US" localize="false">SUM</paragraph>
</tablecell>
<tablecell>
<paragraph id="par_id3154536" role="tablecontent" xml-lang="en-US">Calculates the sum of the values of records for the associated fields.</paragraph>
</tablecell>
</tablerow>
<tablerow>
<tablecell>
<paragraph id="par_id3148820" role="tablecontent" xml-lang="en-US">Group</paragraph>
</tablecell>
<tablecell>
<paragraph id="par_id3145375" role="tablecontent" xml-lang="en-US" localize="false">GROUP BY</paragraph>
</tablecell>
<tablecell>
<paragraph id="par_id3149438" role="tablecontent" xml-lang="en-US">Groups query data according to the selected field name. Functions are executed according to the specified groups. In SQL, this option corresponds to the GROUP BY clause. If a criterion is added, this entry appears in the SQL HAVING sub-clause.</paragraph>
</tablecell>
</tablerow>
</table>
<paragraph id="par_id3156038" role="paragraph" xml-lang="en-US">You can also enter function calls directly into the SQL statement. The syntax is:</paragraph>
<paragraph id="par_id3156340" role="code" xml-lang="en-US">SELECT FUNCTION(column) FROM table.</paragraph>
<paragraph id="par_id3155075" role="paragraph" xml-lang="en-US">For example, the function call in SQL for calculating a sum is:</paragraph>
<sqlcode>
<paragraph id="par_id3154591" role="sqlcode" xml-lang="en-US">SELECT SUM("Price") FROM "Article".</paragraph>
</sqlcode>
<paragraph id="par_id3159205" role="paragraph" xml-lang="en-US">Except for the <emph>Group</emph> function, the above functions are called Aggregate functions. These are functions that calculate data to create summaries from the results. Additional functions that are not listed in the list box might be also possible. These depend on the specific database engine in use and on the current functionality provided by the Base driver used to connect to that database engine.</paragraph>
<paragraph id="par_id3148651" role="paragraph" xml-lang="en-US">To use other functions not listed in the list box, you must enter them manually under <emph>Field</emph>.</paragraph>
<paragraph id="par_id3155098" role="paragraph" xml-lang="en-US">You can also assign aliases to function calls. If you do not want to display the query string in the column header, enter a desired substitute name under <emph>Alias</emph>.</paragraph>
<paragraph id="par_id3155539" role="paragraph" xml-lang="en-US">The corresponding function in an SQL statement is:</paragraph>
<paragraph id="par_id3149425" role="code" xml-lang="en-US">SELECT FUNCTION() AS alias FROM table</paragraph>
<section id="example">
<paragraph id="par_id3144431" role="paragraph" xml-lang="en-US">Example:</paragraph>
</section>
<sqlcode>
<paragraph id="par_id3154614" role="sqlcode" xml-lang="en-US">SELECT COUNT(*) AS count FROM "Item"</paragraph>
</sqlcode>
<note id="par_id3154610">If you run such a function, you cannot insert any additional columns for the query other than as an argument in a "Group" function.</note>
<paragraph id="par_id3154644" role="paragraph" xml-lang="en-US"> <emph>Examples</emph> </paragraph>
<paragraph id="par_id3151120" role="paragraph" xml-lang="en-US">In the following example, a query is run through two tables: an "Item" table with the "Item_No" field and a "Suppliers" table with the "Supplier_Name" field. In addition, both tables have a common field name "Supplier_No."</paragraph>
<paragraph id="par_id3155144" role="paragraph" xml-lang="en-US">The following steps are required to create a query containing all suppliers who deliver more than three items.</paragraph>
<list type="ordered">
<listitem>
<paragraph id="par_id3153240" role="listitem" xml-lang="en-US">Insert the "Item" and "Suppliers" tables into the query design.</paragraph>
</listitem>
<listitem>
<paragraph id="par_id3148807" role="listitem" xml-lang="en-US">Link the "Supplier_No" fields of the two tables if there is not already a relation of this type.</paragraph>
</listitem>
<listitem>
<paragraph id="par_id3161652" role="listitem" xml-lang="en-US">Double-click on the "Item_No" field from the "Item" table. Display the <emph>Function</emph> line using the context menu and select the Count function.</paragraph>
</listitem>
<listitem>
<paragraph id="par_id3151009" role="listitem" xml-lang="en-US">Enter >3 as a criterion and disable the Visible field.</paragraph>
</listitem>
<listitem>
<paragraph id="par_id3145601" role="listitem" xml-lang="en-US">Double-click the "Supplier_Name" field in the "Suppliers" table and choose the Group function.</paragraph>
</listitem>
<listitem>
<paragraph id="par_id3147512" role="listitem" xml-lang="en-US">Run the query.</paragraph>
</listitem>
</list>
<paragraph id="par_id3148638" role="paragraph" xml-lang="en-US">If the "price" (for the individual price of an article) and "Supplier_No" (for the supplier of the article) fields exist in the "Item" table, you can obtain the average price of the item that a supplier provides with the following query:</paragraph>
<list type="ordered">
<listitem>
<paragraph id="par_id3153045" role="listitem" xml-lang="en-US">Insert the "Item" table into the query design.</paragraph>
</listitem>
<listitem>
<paragraph id="par_id3149802" role="listitem" xml-lang="en-US">Double-click the "Price" and "Supplier_No" fields.</paragraph>
</listitem>
<listitem>
<paragraph id="par_id3153554" role="listitem" xml-lang="en-US">Enable the <emph>Function</emph> line and select the Average function from the "Price" field.</paragraph>
</listitem>
<listitem>
<paragraph id="par_id3155597" role="listitem" xml-lang="en-US">You can also enter "Average" in the line for the alias name (without quotation marks).</paragraph>
</listitem>
<listitem>
<paragraph id="par_id3151191" role="listitem" xml-lang="en-US">Choose Group for the "Supplier_No" field.</paragraph>
</listitem>
<listitem>
<paragraph id="par_id3155547" role="listitem" xml-lang="en-US">Run the query.</paragraph>
</listitem>
</list>
<paragraph id="par_id3147549" role="paragraph" xml-lang="en-US">The following context menu commands and symbols are available:</paragraph>
<h3 id="hd_id3154172">Functions</h3>
<paragraph id="par_id3150414" role="paragraph" xml-lang="en-US"><ahelp hid="HID_QRYDGN_ROW_FUNCTION">Shows or hides a row for the selection of functions.</ahelp></paragraph>
<h3 id="hd_id3149872">Table Name</h3>
<paragraph id="par_id3147246" role="paragraph" xml-lang="en-US"><ahelp hid="HID_QRYDGN_ROW_FUNCTION">Shows or hides the row for the table name.</ahelp></paragraph>
<h3 id="hd_id3145117">Alias Name</h3>
<paragraph id="par_id3155754" role="paragraph" xml-lang="en-US"><ahelp hid="HID_QRYDGN_ROW_FUNCTION">Shows or hides the row for the alias name.</ahelp></paragraph>
<h3 id="hd_id3153298">Distinct Values</h3>
<paragraph id="par_id3147500" role="paragraph" xml-lang="en-US"><ahelp hid="HID_QRYDGN_ROW_FUNCTION">Retrieves only distinct values from the query.</ahelp> This applies to multiple records that might contain several repeating occurrences of data in the selected fields. If the <emph>Distinct Values</emph> command is active, you should only see one record in the query (DISTINCT). Otherwise, you will see all records corresponding to the query criteria (ALL).</paragraph>
<paragraph id="par_id3150436" role="paragraph" xml-lang="en-US">For example, if the name "Smith" occurs several times in your address database, you can choose the<emph> Distinct Values</emph> command to specify in the query that the name "Smith" will occur only once.</paragraph>
<paragraph id="par_id3152352" role="paragraph" xml-lang="en-US">For a query involving several fields, the combination of values from all fields must be unique so that the result can be formed from a specific record. For example, you have "Smith in Chicago" once in your address book and "Smith in London" twice. With the<emph> Distinct Values</emph> command, the query will use the two fields "last name" and "city" and return the query result "Smith in Chicago" once and "Smith in London" once.</paragraph>
<paragraph id="par_id3149825" role="paragraph" xml-lang="en-US">In SQL, this command corresponds to the DISTINCT predicate.</paragraph>
<h3 id="hd_id3153290">Limit</h3>
<paragraph id="par_id3147501" role="paragraph" xml-lang="en-US"><ahelp hid="HID_QRYDGN_ROW_FUNCTION">Allows you to limit the maximum number of records returned by a query.</ahelp></paragraph>
<paragraph id="par_id3152350" role="paragraph" xml-lang="en-US">If a <emph>Limit</emph> construction is added, you will get at most as many rows as the number you specify. Otherwise, you will see all records corresponding to the query criteria.</paragraph>
<h3 id="hd_id3148926">Formulating filter conditions</h3>
<section id="query_criteria">
<paragraph id="par_id3153162" role="paragraph" xml-lang="en-US">When formulating filter conditions, various operators and commands are available to you. Apart from the relational operators, there are SQL-specific commands that query the content of database fields. If you use these commands in the $[officename] syntax, $[officename] automatically converts these into the corresponding SQL syntax via an internal parser. You can also enter the SQL command directly and bypass the internal parser. The following tables give an overview of the operators and commands:</paragraph>
<table id="tbl_id3152803">
<tablerow>
<tablecell>
<paragraph id="par_id3149044" role="tablehead" xml-lang="en-US">Operator</paragraph>
</tablecell>
<tablecell>
<paragraph id="par_id3152471" role="tablehead" xml-lang="en-US">Meaning</paragraph>
</tablecell>
<tablecell>
<paragraph id="par_id3147407" role="tablehead" xml-lang="en-US">Condition is satisfied if...</paragraph>
</tablecell>
</tablerow>
<tablerow>
<tablecell>
<paragraph id="par_id3156161" role="tablecontent" xml-lang="en-US" localize="false">=</paragraph>
</tablecell>
<tablecell>
<paragraph id="par_id3153026" role="tablecontent" xml-lang="en-US">equal to</paragraph>
</tablecell>
<tablecell>
<paragraph id="par_id3148895" role="tablecontent" xml-lang="en-US">... the content of the field is identical to the indicated expression.</paragraph>
<paragraph id="par_id3153120" role="tablecontent" xml-lang="en-US">The operator = will not be displayed in the query fields. If you enter a value without any operator, the = operator is automatically assumed.</paragraph>
</tablecell>
</tablerow>
<tablerow>
<tablecell>
<paragraph id="par_id3150470" role="tablecontent" xml-lang="en-US" localize="false"><></paragraph>
</tablecell>
<tablecell>
<paragraph id="par_id3145223" role="tablecontent" xml-lang="en-US">not equal to</paragraph>
</tablecell>
<tablecell>
<paragraph id="par_id3145635" role="tablecontent" xml-lang="en-US">... the content of the field does not correspond to the specified expression.</paragraph>
</tablecell>
</tablerow>
<tablerow>
<tablecell>
<paragraph id="par_id3153015" role="tablecontent" xml-lang="en-US" localize="false">></paragraph>
</tablecell>
<tablecell>
<paragraph id="par_id3146815" role="tablecontent" xml-lang="en-US">greater than</paragraph>
</tablecell>
<tablecell>
<paragraph id="par_id3149150" role="tablecontent" xml-lang="en-US">... the content of the field is greater than the specified expression.</paragraph>
</tablecell>
</tablerow>
<tablerow>
<tablecell>
<paragraph id="par_id3147270" role="tablecontent" xml-lang="en-US" localize="false"><</paragraph>
</tablecell>
<tablecell>
<paragraph id="par_id3147379" role="tablecontent" xml-lang="en-US">less than</paragraph>
</tablecell>
<tablecell>
<paragraph id="par_id3150375" role="tablecontent" xml-lang="en-US">... the content of the field is less than the specified expression.</paragraph>
</tablecell>
</tablerow>
<tablerow>
<tablecell>
<paragraph id="par_id3149787" role="tablecontent" xml-lang="en-US" localize="false">>=</paragraph>
</tablecell>
<tablecell>
<paragraph id="par_id3150636" role="tablecontent" xml-lang="en-US">greater than or equal to</paragraph>
</tablecell>
<tablecell>
<paragraph id="par_id3154584" role="tablecontent" xml-lang="en-US">... the content of the field is greater than or equal to the specified expression.</paragraph>
</tablecell>
</tablerow>
<tablerow>
<tablecell>
<paragraph id="par_id3157964" role="tablecontent" xml-lang="en-US" localize="false"><=</paragraph>
</tablecell>
<tablecell>
<paragraph id="par_id3154052" role="tablecontent" xml-lang="en-US">less than or equal to</paragraph>
</tablecell>
<tablecell>
<paragraph id="par_id3157902" role="tablecontent" xml-lang="en-US">... the content of the field is less than or equal to the specified expression.</paragraph>
</tablecell>
</tablerow>
</table>
<table id="tbl_id3153376">
<tablerow>
<tablecell>
<paragraph id="par_id3154630" role="tablehead" xml-lang="en-US">$[officename] command</paragraph>
</tablecell>
<tablecell>
<paragraph id="par_id3150484" role="tablehead" xml-lang="en-US">SQL command</paragraph>
</tablecell>
<tablecell>
<paragraph id="par_id3154158" role="tablehead" xml-lang="en-US">Meaning</paragraph>
</tablecell>
<tablecell>
<paragraph id="par_id3149433" role="tablehead" xml-lang="en-US">Condition is satisfied if...</paragraph>
</tablecell>
</tablerow>
<tablerow>
<tablecell>
<paragraph id="par_id3154275" role="tablecontent" xml-lang="en-US" localize="false">IS EMPTY</paragraph>
</tablecell>
<tablecell>
<paragraph id="par_id3149893" role="tablecontent" xml-lang="en-US" localize="false">IS NULL</paragraph>
</tablecell>
<tablecell>
<paragraph id="par_id3143236" role="tablecontent" xml-lang="en-US">is null</paragraph>
</tablecell>
<tablecell>
<paragraph id="par_id3154744" role="tablecontent" xml-lang="en-US">... the field contains no data. For Yes/No fields with three possible states, this command automatically queries the undetermined state (neither Yes nor No).</paragraph>
</tablecell>
</tablerow>
<tablerow>
<tablecell>
<paragraph id="par_id3146940" role="tablecontent" xml-lang="en-US" localize="false">IS NOT EMPTY</paragraph>
</tablecell>
<tablecell>
<paragraph id="par_id3147471" role="tablecontent" xml-lang="en-US" localize="false">IS NOT NULL</paragraph>
</tablecell>
<tablecell>
<paragraph id="par_id3151229" role="tablecontent" xml-lang="en-US">is not empty</paragraph>
</tablecell>
<tablecell>
<paragraph id="par_id3145304" role="tablecontent" xml-lang="en-US">... the field is not empty, i.e it contains data.</paragraph>
</tablecell>
</tablerow>
<tablerow>
<tablecell>
<paragraph id="par_id3153578" role="tablecontent" xml-lang="en-US" localize="false">LIKE</paragraph>
<paragraph id="par_id3153891" role="tablecontent" xml-lang="en-US">placeholder (*) for any number of characters</paragraph>
<paragraph id="par_id3148887" role="tablecontent" xml-lang="en-US">placeholder (?) for exactly one character</paragraph>
</tablecell>
<tablecell>
<paragraph id="par_id3148623" role="tablecontent" xml-lang="en-US" localize="false">LIKE</paragraph>
<bookmark xml-lang="en-US" branch="index" id="bm_id3157985">
<bookmark_value>placeholders; in SQL queries</bookmark_value>
</bookmark>
<paragraph id="par_id3157985" role="tablecontent" xml-lang="en-US">placeholder (%) for any number of characters</paragraph>
<paragraph id="par_id3147422" role="tablecontent" xml-lang="en-US">Placeholder (_) for exactly one character</paragraph>
</tablecell>
<tablecell>
<paragraph id="par_id3154845" role="tablecontent" xml-lang="en-US">is an element of</paragraph>
</tablecell>
<tablecell>
<paragraph id="par_id3156130" role="tablecontent" xml-lang="en-US">... the data field contains the indicated expression. The (*) placeholder indicates whether the expression x occurs at the beginning of (x*), at the end of (*x) or inside the field content (*x*). You can enter as a placeholder in SQL queries either the SQL % character or the familiar (*) file system placeholder in the %PRODUCTNAME interface.</paragraph>
<paragraph id="par_id3150271" role="tablecontent" xml-lang="en-US">The (*) or (%) placeholder stands for any number of characters. The question mark (?) in the $[officename] interface or the underscore (_) in SQL queries is used to represent exactly one character.</paragraph>
</tablecell>
</tablerow>
<tablerow>
<tablecell>
<paragraph id="par_id3152954" role="tablecontent" xml-lang="en-US" localize="false">NOT LIKE</paragraph>
</tablecell>
<tablecell>
<paragraph id="par_id3161669" role="tablecontent" xml-lang="en-US" localize="false">NOT LIKE</paragraph>
</tablecell>
<tablecell>
<paragraph id="par_id3159141" role="tablecontent" xml-lang="en-US">Is not an element of</paragraph>
</tablecell>
<tablecell>
<paragraph id="par_id3161664" role="tablecontent" xml-lang="en-US">... the field does not contain data having the specified expression.</paragraph>
</tablecell>
</tablerow>
<tablerow>
<tablecell>
<paragraph id="par_id3149185" role="tablecontent" xml-lang="en-US" localize="false">BETWEEN x AND y</paragraph>
</tablecell>
<tablecell>
<paragraph id="par_id3151259" role="tablecontent" xml-lang="en-US" localize="false">BETWEEN x AND y</paragraph>
</tablecell>
<tablecell>
<paragraph id="par_id3159184" role="tablecontent" xml-lang="en-US">falls within the interval [x,y]</paragraph>
</tablecell>
<tablecell>
<paragraph id="par_id3154395" role="tablecontent" xml-lang="en-US">... the field contains a data value that lies between the two values x and y.</paragraph>
</tablecell>
</tablerow>
<tablerow>
<tablecell>
<paragraph id="par_id3154561" role="tablecontent" xml-lang="en-US" localize="false">NOT BETWEEN x AND y</paragraph>
</tablecell>
<tablecell>
<paragraph id="par_id3148753" role="tablecontent" xml-lang="en-US" localize="false">NOT BETWEEN x AND y</paragraph>
</tablecell>
<tablecell>
<paragraph id="par_id3155498" role="tablecontent" xml-lang="en-US">Does not fall within the interval [x,y]</paragraph>
</tablecell>
<tablecell>
<paragraph id="par_id3148992" role="tablecontent" xml-lang="en-US">... the field contains a data value that does not lie between the two values x and y.</paragraph>
</tablecell>
</tablerow>
<tablerow>
<tablecell>
<paragraph id="par_id3149995" role="tablecontent" xml-lang="en-US" localize="false">IN (a; b; c...)</paragraph>
<paragraph id="par_id3159167" role="tablecontent" xml-lang="en-US">Note that semicolons are used as separators in all value lists!</paragraph>
</tablecell>
<tablecell>
<paragraph id="par_id3159085" role="tablecontent" xml-lang="en-US" localize="false">IN (a, b, c...)</paragraph>
</tablecell>
<tablecell>
<paragraph id="par_id3154809" role="tablecontent" xml-lang="en-US">contains a, b, c...</paragraph>
</tablecell>
<tablecell>
<paragraph id="par_id3148399" role="tablecontent" xml-lang="en-US">... the field name contains one of the specified expressions a, b, c,... Any number of expressions can be specified, and the result of the query is determined by a boolean OR operator. The expressions a, b, c... can be either numbers or characters</paragraph>
</tablecell>
</tablerow>
<tablerow>
<tablecell>
<paragraph id="par_id3154112" role="tablecontent" xml-lang="en-US" localize="false">NOT IN (a; b; c...)</paragraph>
</tablecell>
<tablecell>
<paragraph id="par_id3153544" role="tablecontent" xml-lang="en-US" localize="false">NOT IN (a, b, c...)</paragraph>
</tablecell>
<tablecell>
<paragraph id="par_id3150679" role="tablecontent" xml-lang="en-US">does not contain a, b, c...</paragraph>
</tablecell>
<tablecell>
<paragraph id="par_id3158439" role="tablecontent" xml-lang="en-US">... the field does not contain one of the specified expressions a, b, c,...</paragraph>
</tablecell>
</tablerow>
<tablerow>
<tablecell>
<paragraph id="par_id3145145" role="tablecontent" xml-lang="en-US" localize="false">= TRUE</paragraph>
</tablecell>
<tablecell>
<paragraph id="par_id3146804" role="tablecontent" xml-lang="en-US" localize="false">= TRUE</paragraph>
</tablecell>
<tablecell>
<paragraph id="par_id3149248" role="tablecontent" xml-lang="en-US">has the value True</paragraph>
</tablecell>
<tablecell>
<paragraph id="par_id3148524" role="tablecontent" xml-lang="en-US">... the field name has the value True.</paragraph>
</tablecell>
</tablerow>
<tablerow>
<tablecell>
<paragraph id="par_id3159212" role="tablecontent" xml-lang="en-US" localize="false">= FALSE</paragraph>
</tablecell>
<tablecell>
<paragraph id="par_id3144751" role="tablecontent" xml-lang="en-US" localize="false">= FALSE</paragraph>
</tablecell>
<tablecell>
<paragraph id="par_id3149955" role="tablecontent" xml-lang="en-US">has the value false</paragraph>
</tablecell>
<tablecell>
<paragraph id="par_id3146850" role="tablecontent" xml-lang="en-US">... the field data value is set to false.</paragraph>
</tablecell>
</tablerow>
</table>
<h3 id="hd_id3155954">Examples</h3>
<table id="tbl_id3083279">
<tablerow>
<tablecell>
<paragraph id="par_id3153792" role="paragraph" xml-lang="en-US">='Ms.'</paragraph>
</tablecell>
<tablecell>
<paragraph id="par_id3150948" role="paragraph" xml-lang="en-US">returns field names with the field content "Ms."</paragraph>
</tablecell>
</tablerow>
<tablerow>
<tablecell>
<paragraph id="par_id315379A" role="paragraph" xml-lang="en-US" localize="false"><'2001-01-10'</paragraph>
</tablecell>
<tablecell>
<paragraph id="par_id315094A" role="paragraph" xml-lang="en-US">returns dates that occurred before January 10, 2001</paragraph>
</tablecell>
</tablerow>
<tablerow>
<tablecell>
<paragraph id="par_id3150333" role="paragraph" xml-lang="en-US">LIKE 'g?ve'</paragraph>
</tablecell>
<tablecell>
<paragraph id="par_id3147332" role="paragraph" xml-lang="en-US">returns records with field content such as "give" and "gave".</paragraph>
</tablecell>
</tablerow>
<tablerow>
<tablecell>
<paragraph id="par_id3146062" role="paragraph" xml-lang="en-US" localize="false">LIKE 'S*'</paragraph>
</tablecell>
<tablecell>
<paragraph id="par_id3155350" role="paragraph" xml-lang="en-US">returns records with field contents such as "Sun".</paragraph>
</tablecell>
</tablerow>
<tablerow>
<tablecell>
<paragraph id="par_id3152883" role="paragraph" xml-lang="en-US" localize="false">BETWEEN 10 AND 20</paragraph>
</tablecell>
<tablecell>
<paragraph id="par_id3159406" role="paragraph" xml-lang="en-US">returns records with field content between the values 10 and 20. (The fields can be either text fields or number fields).</paragraph>
</tablecell>
</tablerow>
<tablerow>
<tablecell>
<paragraph id="par_id3148765" role="paragraph" xml-lang="en-US" localize="false">IN (1; 3; 5; 7)</paragraph>
</tablecell>
<tablecell>
<paragraph id="par_id3149712" role="paragraph" xml-lang="en-US">returns records with the values 1, 3, 5, 7. If the field name contains an item number, for example, you can create a query that returns the item having the specified number.</paragraph>
</tablecell>
</tablerow>
<tablerow>
<tablecell>
<paragraph id="par_id3152948" role="paragraph" xml-lang="en-US">NOT IN ('Smith')</paragraph>
</tablecell>
<tablecell>
<paragraph id="par_id3147279" role="paragraph" xml-lang="en-US">returns records that do not contain "Smith".</paragraph>
</tablecell>
</tablerow>
</table>
</section>
<paragraph id="par_id3146073" role="paragraph" xml-lang="en-US"> <emph>Like </emph>Escape Sequence: {escape 'escape-character'}</paragraph>
<embed href="text/sdatabase/02010100.xhp#example"/>
<sqlcode>
<paragraph role="sqlcode" id="par_id441652550335953" xml-lang="en-US" localize="false">SELECT * FROM Item WHERE ItemName LIKE 'The *%' {escape '*'}</paragraph>
</sqlcode>
<paragraph id="par_id3148541" role="paragraph" xml-lang="en-US">The example will give you all of the entries where the item name begins with 'The *'. This means that you can also search for characters that would otherwise be interpreted as placeholders, such as *, ?, _, % or the period.</paragraph>
<paragraph id="par_id3150572" role="paragraph" xml-lang="en-US"> <emph>Outer Join</emph> Escape Sequence: {oj outer-join}</paragraph>
<embed href="text/sdatabase/02010100.xhp#example"/>
<sqlcode>
<paragraph role="sqlcode" id="par_id841652550235363" xml-lang="en-US" localize="false">SELECT Article.* FROM {oj item LEFT OUTER JOIN orders ON item.no=orders.ANR}</paragraph>
</sqlcode>
<h3 id="hd_id3153674">Querying text fields</h3>
<paragraph id="par_id3149134" role="paragraph" xml-lang="en-US">To query the content of a text field, you must put the expression between single quotes. The distinction between uppercase and lowercase letters depends on the database in use. LIKE, by definition, is case-sensitive (though some databases don't interpret this strictly).</paragraph>
<h3 id="hd_id3149302">Querying date fields</h3>
<paragraph id="par_id3157998" role="paragraph" xml-lang="en-US"> <emph>Date fields</emph> are represented as #Date# to clearly identify them as dates. Date, time and date/time constants (literals) used in conditions can be of either the SQL Escape Syntax type, or default SQL2 syntax.</paragraph>
<table id="tbl_id3156186">
<tablerow>
<tablecell>
<paragraph id="par_id31537341" role="tablehead" xml-lang="en-US">Date Type Element</paragraph>
</tablecell>
<tablecell>
<paragraph id="par_id31537342" role="tablehead" xml-lang="en-US">SQL Escape syntax #1 - may be obsolete</paragraph>
</tablecell>
<tablecell>
<paragraph id="par_id31537343" role="tablehead" xml-lang="en-US">SQL Escape syntax #2</paragraph>
</tablecell>
<tablecell>
<paragraph id="par_id31537344" role="tablehead" xml-lang="en-US">SQL2 syntax</paragraph>
</tablecell>
</tablerow>
<tablerow>
<tablecell>
<paragraph id="par_id315913111" role="paragraph" xml-lang="en-US">Date</paragraph>
</tablecell>
<tablecell>
<paragraph id="par_id315913112" role="paragraph" xml-lang="en-US" localize="false">{D'YYYY-MM-DD'}</paragraph>
</tablecell>
<tablecell>
<paragraph id="par_id314975313" role="paragraph" xml-lang="en-US" localize="false">{d 'YYYY-MM-DD'}</paragraph>
</tablecell>
<tablecell>
<paragraph id="par_id314975314" role="paragraph" xml-lang="en-US" localize="false">'YYYY-MM-DD'</paragraph>
</tablecell>
</tablerow>
<tablerow>
<tablecell>
<paragraph id="par_id31559471" role="paragraph" xml-lang="en-US">Time</paragraph>
</tablecell>
<tablecell>
<paragraph id="par_id31559472" role="paragraph" xml-lang="en-US" localize="false">{D'HH:MM:SS'}</paragraph>
</tablecell>
<tablecell>
<paragraph id="par_id31559473" role="paragraph" xml-lang="en-US" localize="false">{t 'HH:MI:SS[.SS]'} </paragraph>
</tablecell>
<tablecell>
<paragraph id="par_id31559474" role="paragraph" xml-lang="en-US" localize="false">'HH:MI:SS[.SS]' </paragraph>
</tablecell>
</tablerow>
<tablerow>
<tablecell>
<paragraph id="par_id31509641" role="paragraph" xml-lang="en-US">DateTime</paragraph>
</tablecell>
<tablecell>
<paragraph id="par_id31509642" role="paragraph" xml-lang="en-US" localize="false">{D'YYYY-MM-DD HH:MM:SS'}</paragraph>
</tablecell>
<tablecell>
<paragraph id="par_id31509643" role="paragraph" xml-lang="en-US" localize="false">{ts 'YYYY-MM-DD HH:MI:SS[.SS]'} </paragraph>
</tablecell>
<tablecell>
<paragraph id="par_id31509644" role="paragraph" xml-lang="en-US" localize="false">'YYYY-MM-DD HH:MI:SS[.SS]' </paragraph>
</tablecell>
</tablerow>
</table>
<embed href="text/sdatabase/02010100.xhp#example"/>
<sqlcode>
<paragraph role="sqlcode" id="par_id661652550524160" xml-lang="en-US" localize="false">SELECT {d '1999-12-31'} FROM world.years</paragraph>
</sqlcode>
<embed href="text/sdatabase/02010100.xhp#example"/>
<sqlcode>
<paragraph role="sqlcode" id="par_id381652550614110" xml-lang="en-US" localize="false">SELECT * FROM mytable WHERE years='1999-12-31'</paragraph>
</sqlcode>
<paragraph id="par_id3150510" role="paragraph" xml-lang="en-US">All date expressions (date literals) must be enclosed with single quotation marks. (Consult the reference for the particular database and connector you are using for more details.)</paragraph>
<h3 id="hd_id3150427">Querying Yes/No fields</h3>
<paragraph id="par_id3149523" role="paragraph" xml-lang="en-US">To query Yes/No fields, use the following syntax for dBASE tables:</paragraph>
<table id="tbl_id3150146">
<tablerow>
<tablecell>
<paragraph id="par_id3153180" role="tablehead" xml-lang="en-US">Status</paragraph>
</tablecell>
<tablecell>
<paragraph id="par_id3147481" role="tablehead" xml-lang="en-US">Query criterion</paragraph>
</tablecell>
<tablecell>
<paragraph id="par_id3155187" role="tablehead" xml-lang="en-US">Example</paragraph>
</tablecell>
</tablerow>
<tablerow>
<tablecell>
<paragraph id="par_id3156092" role="tablecontent" xml-lang="en-US">Yes</paragraph>
</tablecell>
<tablecell>
<paragraph id="par_id3152414" role="tablecontent" xml-lang="en-US">for dBASE tables: not equal to any given value</paragraph>
</tablecell>
<tablecell>
<paragraph id="par_id3151265" role="tablecontent" xml-lang="en-US">=1 returns all records where the Yes/No field has the status "Yes" or "On" (selected in black),</paragraph>
</tablecell>
</tablerow>
<tablerow>
<tablecell>
<paragraph id="par_id3152450" role="tablecontent" xml-lang="en-US">No</paragraph>
</tablecell>
<tablecell>
<paragraph id="par_id3150997" role="tablecontent" xml-lang="en-US">.</paragraph>
</tablecell>
<tablecell>
<paragraph id="par_id3155331" role="tablecontent" xml-lang="en-US">=0 returns all records for which the Yes/No field has the status "No" or "Off" (no selection).</paragraph>
</tablecell>
</tablerow>
<tablerow>
<tablecell>
<paragraph id="par_id3154179" role="tablecontent" xml-lang="en-US">Null</paragraph>
</tablecell>
<tablecell>
<paragraph id="par_id3147035" role="tablecontent" xml-lang="en-US">IS NULL</paragraph>
</tablecell>
<tablecell>
<paragraph id="par_id3159385" role="tablecontent" xml-lang="en-US">IS NULL returns all records for which the Yes/No field has neither of the states Yes or No (selected in gray).</paragraph>
</tablecell>
</tablerow>
</table>
<note id="par_id3157888">The syntax depends on the database system used. You should also note that Yes/No fields can be defined differently (only 2 states instead of 3).</note>
<h3 id="hd_id3145772">Parameter queries</h3>
<paragraph id="par_id191120151905346795" role="paragraph" xml-lang="en-US">Parameter queries allow the user to input values at run-time. These values are used within the criteria for selecting the records to be displayed. Each such value has a parameter name associated with it, which is used to prompt the user when the query is run. </paragraph>
<paragraph id="par_id191120151905439551" role="paragraph" xml-lang="en-US">Parameter names are preceded by a colon in both the Design and SQL views of a query. This can be used wherever a value can appear. If the same value is to appear more than once in the query, the same parameter name is used.</paragraph>
<paragraph id="par_id191120151905518123" role="paragraph" xml-lang="en-US">In the simplest case, where the user enters a value which is matched for equality, the parameter name with its preceding colon is simply entered in the Criterion row. In <link href="text/sdatabase/02010100.xhp#sqlmode">SQL mode</link> this should be typed as <item type="input">WHERE "Field" = :Parameter_name</item></paragraph>
<warning id="par_id191120151905584287">Parameter names may not contain any of the characters <item type="input"><space>`!"$%^*()+={}[]@'~#<>?/,</item>. They may not be the same as field names or SQL reserved words. They may be the same as aliases.</warning>
<tip id="par_id191120151931441881">A useful construction for selecting records based on parts of a text field's content is to add a hidden column with <item type="input">"LIKE '%' || :Part_of_field || '%'"</item> as the criterion. This will select records with an exact match. If a case-insensitive test is wanted, one solution is to use <item type="input">LOWER (Field_Name)</item> as the field and <item type="input">LIKE LOWER ( '%' || :Part_of_field || '%' )</item> as the criterion. Note that the spaces in the criterion are important; if they are left out the SQL parser interprets the entire criterion as a string to be matched. In <link href="text/sdatabase/02010100.xhp#sqlmode">SQL mode</link> this should be typed as <item type="input">LOWER ( "Field_Name" ) LIKE LOWER ( '%' || :Part_of_field || '%' )</item>.</tip>
<paragraph id="par_id3150585" role="paragraph" xml-lang="en-US">Parameter queries may be used as the data source for <link href="text/shared/02/01170203.xhp" name="subforms">subforms</link>, to allow the user to restrict the displayed records.</paragraph>
<h3 id="hd_id3151035">Parameter Input</h3>
<paragraph id="par_id3153596" role="paragraph" xml-lang="en-US"><ahelp hid="HID_QRYDGN_ROW_FUNCTION">The <emph>Parameter Input</emph> dialog asks the user to enter the parameter values. Enter a value for each query parameter and confirm by clicking <emph>OK</emph> or typing <emph>Enter</emph>.</ahelp></paragraph>
<paragraph id="par_id191120151924165870" role="paragraph" xml-lang="en-US">The values entered by the user may consist of any characters which are allowable for the SQL for the relevant criterion; this may depend on the underlying database system.</paragraph>
<tip id="par_id191120151939594217">The user can use the SQL wild-card characters "%" (arbitrary string) or "_" (arbitrary single character) as part of the value to retrieve records with more complex criteria.</tip>
<section id="sqlmode">
<h2 id="hd_id3145181">SQL Mode</h2>
<paragraph id="par_id3147013" role="paragraph" xml-lang="en-US">SQL stands for "Structured Query Language" and describes instructions for updating and administering relational databases.</paragraph>
<paragraph id="par_id3152570" role="paragraph" xml-lang="en-US">In $[officename] you do not need any knowledge of SQL for most queries, since you do not have to enter the SQL code. If you create a query in the query designer, $[officename] automatically converts your instructions into the corresponding SQL syntax. If, with the help of the <emph>Switch Design View On/Off </emph>button, you change to the SQL view, you can see the SQL commands for a query that has already been created.</paragraph>
<paragraph id="par_id3152412" role="paragraph" xml-lang="en-US">You can formulate your query directly in SQL code. Note, however, that the special syntax is dependent upon the database system that you use.</paragraph>
<paragraph id="par_id3146842" role="paragraph" xml-lang="en-US">If you enter the SQL code manually, you can create SQL-specific queries that are not supported by the graphical interface in the <emph>Query designer</emph>. These queries must be executed in native SQL mode.</paragraph>
<paragraph id="par_id3149632" role="paragraph" xml-lang="en-US">By clicking the <link href="text/shared/02/14030000.xhp" name="Run SQL command directly"><emph>Run SQL command directly</emph></link> icon in the SQL view, you can formulate a query that is not processed by $[officename] and sent directly to the database engine.</paragraph>
</section>
</body>
</helpdocument>
|