-
Notifications
You must be signed in to change notification settings - Fork 0
/
z_output.h
11579 lines (11058 loc) · 754 KB
/
z_output.h
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
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#ifndef Z_OUTPUT_H
#define Z_OUTPUT_H
// OUTPUT (test of CTORS, insert & selects):
/*
================================
t1:
[Last| [Smith|6]
[Oliver|5]
[Olajuwon|2 3]
[Horry|0]
[Fisher|1]
[Durden|4]
]
[First| [Tyler|4]
[Rick|6]
[John|5]
[Hakeem|2]
[Derek|1]
[Bob|0]
[Abdul|3]
]
[Dept| [Natural Sciences|6]
[Math|2 4 5]
[English|3]
[CS|0 1]
]
============================================================
t2:
[Last| [Smith|6]
[Oliver|5]
[Olajuwon|2 3]
[Horry|0]
[Fisher|1]
[Durden|4]
]
[First| [Tyler|4]
[Rick|6]
[John|5]
[Hakeem|2]
[Derek|1]
[Bob|0]
[Abdul|3]
]
[Dept| [Natural Sciences|6]
[Math|2 4 5]
[English|3]
[CS|0 1]
]
============================================================
t2:
[Last| [Smith|6]
[Oliver|5]
[Olajuwon|2 3]
[Jackman|7]
[Horry|0]
[Fisher|1]
[Durden|4]
]
[First| [Tyler|4]
[Rick|6]
[John|5]
[Hugh|7]
[Hakeem|2]
[Derek|1]
[Bob|0]
[Abdul|3]
]
[Dept| [Payroll|7]
[Natural Sciences|6]
[Math|2 4 5]
[English|3]
[CS|0 1]
]
============================================================
t3:
[Last| [Smith|6]
[Oliver|5]
[Olajuwon|2 3]
[Jackman|7]
[Horry|0]
[Fisher|1]
[Durden|4]
]
[First| [Tyler|4]
[Rick|6]
[John|5]
[Hugh|7]
[Hakeem|2]
[Derek|1]
[Bob|0]
[Abdul|3]
]
[Dept| [Payroll|7]
[Natural Sciences|6]
[Math|2 4 5]
[English|3]
[CS|0 1]
]
============================================================
t1:
[Last| [Smith|6]
[Oliver|5]
[Olajuwon|2 3]
[Horry|0]
[Fisher|1]
[Durden|4]
]
[First| [Tyler|4]
[Rick|6]
[John|5]
[Hakeem|2]
[Derek|1]
[Bob|0]
[Abdul|3]
]
[Dept| [Natural Sciences|6]
[Math|2 4 5]
[English|3]
[CS|0 1]
]
t2:
[Last| [Smith|6]
[Oliver|5]
[Olajuwon|2 3]
[Jackman|7]
[Horry|0]
[Fisher|1]
[Durden|4]
]
[First| [Tyler|4]
[Rick|6]
[John|5]
[Hugh|7]
[Hakeem|2]
[Derek|1]
[Bob|0]
[Abdul|3]
]
[Dept| [Payroll|7]
[Natural Sciences|6]
[Math|2 4 5]
[English|3]
[CS|0 1]
]
t3:
[Last| [Smith|6]
[Oliver|5]
[Olajuwon|2 3]
[Jackman|7]
[Horry|0]
[Fisher|1]
[Durden|4]
[Bowman|8]
]
[First| [Tyler|4]
[Rick|6]
[Ky|8]
[John|5]
[Hugh|7]
[Hakeem|2]
[Derek|1]
[Bob|0]
[Abdul|3]
]
[Dept| [Payroll|7]
[Natural Sciences|6]
[Math|2 4 5]
[Languages|8]
[English|3]
[CS|0 1]
]
============================================================
t4:
[Last| [Oliver|2]
[Olajuwon|0]
[Durden|1]
]
[First| [Tyler|1]
[John|2]
[Hakeem|0]
]
[Dept|[Math|0 1 2]
]
t5:
[Last|[Horry|0]
[Fisher|1]
]
t6:
[Last| [Oliver|2]
[Olajuwon|0]
[Durden|1]
]
[First| [Tyler|1]
[John|2]
[Hakeem|0]
]
========================= END TEST =========================
================================
Press <RETURN> to close this window...
*/
// OUTPUT II (parser progress):
/*
================================
Input the command: select Last from school where Dept = Math
Last
Olajuwon
Durden
Oliver
Input the command: quit
================================
Press <RETURN> to close this window...
*/
// OUTPUT III (multiple complex conditions):
/*
> select * from school
==========================================================================================================
|Last |First |Dept |Age |State |
==========================================================================================================
|Horry |Bob |CS |22 |California |
|Fisher |Derek |CS |18 |California |
|Olajuwon |Hakeem |Math |32 |Michigan |
|Olajuwon |Abdul |English |44 |Louisiana |
|Durden |Tyler |Math |18 |New York |
|Oliver |John |Math |22 |North Dakota |
|Smith |Rick |Natural Sciences |52 |Ohio |
|Smith |Steve |Math |23 |Ohio |
|Smith |Josh |Math |42 |Michigan |
|Durden |Elliot |CS |37 |Ohio |
|Kidd |Josh |English |22 |California |
==========================================================================================================
> select Age, First, Dept from school where Dept = Math || (Dept = CS && Age = 22)
================================================================
|Age |First |Dept |
================================================================
|22 |Bob |CS |
|32 |Hakeem |Math |
|18 |Tyler |Math |
|22 |John |Math |
|23 |Steve |Math |
|42 |Josh |Math |
================================================================
> Select First, Last from school where Dept = "Natural Sciences"
Command 'Select First, Last from school where Dept = "Natural Sciences"' not found
^
> select First, Last from school where Dept = "Natural Sciences"
===========================================
|First |Last |
===========================================
|Rick |Smith |
===========================================
> select Age, First, Dept from school where Dept = Math && (Dept = CS && Age = 22)
================================================================
|Age |First |Dept |
================================================================
| EMPTY |
================================================================
> select Age, First, Dept from school where ((State = Ohio) || Dept = CS && Age = 22) || State = "North Dakota"
================================================================
|Age |First |Dept |
================================================================
|22 |Bob |CS |
|22 |John |Math |
================================================================
> slect
Command 'slect ' not found
^
> select * frmmm
Command 'select * frmmm' not found
^
> select * from school where Age = 22
==========================================================================================================
|Last |First |Dept |Age |State |
==========================================================================================================
|Horry |Bob |CS |22 |California |
|Oliver |John |Math |22 |North Dakota |
|Kidd |Josh |English |22 |California |
==========================================================================================================
> quit
Press <RETURN> to close this window...
*/
// OUTPUT IV (SQL SAMPLE RUN):
/*
------ Currently Managed SQL Tables: ------
-------------------------------------------
> batch "_!sampl3"
[0]: batch "_!sampl3"
//****************************************************************************
// CREATE AND INSERT
//****************************************************************************
//---- employee table ----------
[1]: make table employee fields last, first, dep
------ Currently Managed SQL Tables: ------
employee
-------------------------------------------
[2]: insert into employee values Blow, Joe, CS
[3]: insert into employee values Johnson, "Jimmy", Chemistry
[4]: insert into employee values Yang, Bo, CS
[5]: insert into employee values "Jackson", Billy, Math
[6]: insert into employee values Johnson, Billy, "Phys Ed"
[7]: insert into employee values "Van Gogh", "Jim Bob", "Phys Ed"
[8]: select * from employee
======================================================================
| # |last |first |dep |
======================================================================
| 0 |Blow |Joe |CS |
| 1 |Johnson |Jimmy |Chemistry |
| 2 |Yang |Bo |CS |
| 3 |Jackson |Billy |Math |
| 4 |Johnson |Billy |Phys Ed |
| 5 |Van Gogh |Jim Bob |Phys Ed |
======================================================================
//----- student table ----------
[9]: make table student fields fname, lname, major, age
------ Currently Managed SQL Tables: ------
employee
student
-------------------------------------------
[10]: insert into student values Flo, Yao, CS, 20
[11]: insert into student values "Flo", "Jackson", Math, 21
[12]: insert into student values Calvin, Woo, Physics, 22
[13]: insert into student values "Anna Grace", "Del Rio", CS, 22
[14]: select * from student
===========================================================================================
| # |fname |lname |major |age |
===========================================================================================
| 0 |Flo |Yao |CS |20 |
| 1 |Flo |Jackson |Math |21 |
| 2 |Calvin |Woo |Physics |22 |
| 3 |Anna Grace |Del Rio |CS |22 |
===========================================================================================
//****************************************************************************
// SIMPLE SELECT
//****************************************************************************
[15]: select * from student
===========================================================================================
| # |fname |lname |major |age |
===========================================================================================
| 0 |Flo |Yao |CS |20 |
| 1 |Flo |Jackson |Math |21 |
| 2 |Calvin |Woo |Physics |22 |
| 3 |Anna Grace |Del Rio |CS |22 |
===========================================================================================
//------- simple strings -------------------
[16]: select * from student where lname = Jackson
===========================================================================================
| # |fname |lname |major |age |
===========================================================================================
| 0 |Flo |Jackson |Math |21 |
===========================================================================================
//----- quoted strings ---------------------
[17]: select * from student where lname = "Del Rio"
===========================================================================================
| # |fname |lname |major |age |
===========================================================================================
| 0 |Anna Grace |Del Rio |CS |22 |
===========================================================================================
//-------- non-existing string ------------------
[18]: select * from student where lname = "Does Not Exist"
===========================================================================================
| # |fname |lname |major |age |
===========================================================================================
| EMPTY |
===========================================================================================
//****************************************************************************
// RELATIONAL OPERATORS:
//****************************************************************************
//.................
//:Greater Than :
//.................
[19]: select * from student where lname > Yang
===========================================================================================
| # |fname |lname |major |age |
===========================================================================================
| 0 |Flo |Yao |CS |20 |
===========================================================================================
//. . . . . . . . . . . . . (Greater Than: Non-existing) . . . . . . . . . . . . . . . . . . . . .
[20]: select * from student where age > 50
===========================================================================================
| # |fname |lname |major |age |
===========================================================================================
| EMPTY |
===========================================================================================
//. . . . . . . . . . . . . (Greater than: last item) . . . . . . . . . . . . . . . . . .
[21]: select * from student where age > 53
===========================================================================================
| # |fname |lname |major |age |
===========================================================================================
| EMPTY |
===========================================================================================
//. . . . . . . . . . . . . (Greater Than: Passed last item) . . . . . . . . . . . . . . . . . . . . .
[22]: select * from student where age > 54
===========================================================================================
| # |fname |lname |major |age |
===========================================================================================
| EMPTY |
===========================================================================================
//.................
//:Greater Equal :
//.................
[23]: select * from student where lname >= Yang
===========================================================================================
| # |fname |lname |major |age |
===========================================================================================
| 0 |Flo |Yao |CS |20 |
===========================================================================================
//. . . . . . (Greater Equal non-existing: ) . . . . . . . . . . .
[24]: select * from employee where last >= Jack
======================================================================
| # |last |first |dep |
======================================================================
| 0 |Jackson |Billy |Math |
| 1 |Johnson |Jimmy |Chemistry |
| 2 |Johnson |Billy |Phys Ed |
| 3 |Van Gogh |Jim Bob |Phys Ed |
| 4 |Yang |Bo |CS |
======================================================================
//.................
//:Less Than :
//.................
//. . . . . . . . . . . . . (Less Than: Non-existing) . . . . . . . . . . . . . . . . . . . . .
[25]: select * from student where lname < Jackson
===========================================================================================
| # |fname |lname |major |age |
===========================================================================================
| 0 |Anna Grace |Del Rio |CS |22 |
===========================================================================================
//. . . . . . . . . . . . . (Less than: first item) . . . . . . . . . . . . . . . . . .
[26]: select * from student where age < 20
===========================================================================================
| # |fname |lname |major |age |
===========================================================================================
| EMPTY |
===========================================================================================
//. . . . . . . . . . . . . (Less Than: before first item) . . . . . . . . . . . . . . . . . . . . .
[27]: select * from student where age < 19
===========================================================================================
| # |fname |lname |major |age |
===========================================================================================
| EMPTY |
===========================================================================================
//.................
//:Less Equal :
//.................
[28]: select * from student where lname <= Smith
===========================================================================================
| # |fname |lname |major |age |
===========================================================================================
| 0 |Anna Grace |Del Rio |CS |22 |
| 1 |Flo |Jackson |Math |21 |
===========================================================================================
//. . . . . . (Less Equal non-existing: ) . . . . . . . . . . .
[29]: select * from employee where last <= Peach
======================================================================
| # |last |first |dep |
======================================================================
| 0 |Blow |Joe |CS |
| 1 |Jackson |Billy |Math |
| 2 |Johnson |Jimmy |Chemistry |
| 3 |Johnson |Billy |Phys Ed |
======================================================================
//****************************************************************************
// LOGICAL OPERATORS
//****************************************************************************
//.................
//:AND :
//.................
[30]: select * from student where fname = "Flo" and lname = "Yao"
===========================================================================================
| # |fname |lname |major |age |
===========================================================================================
| 0 |Flo |Yao |CS |20 |
===========================================================================================
//.................
//:OR :
//.................
[31]: select * from student where fname = Flo or lname = Jackson
===========================================================================================
| # |fname |lname |major |age |
===========================================================================================
| 0 |Flo |Yao |CS |20 |
| 1 |Flo |Jackson |Math |21 |
===========================================================================================
//.................
//:OR AND :
//.................
[32]: select * from student where fname = Flo or major = CS and age <= 23
===========================================================================================
| # |fname |lname |major |age |
===========================================================================================
| 0 |Flo |Yao |CS |20 |
| 1 |Flo |Jackson |Math |21 |
| 2 |Anna Grace |Del Rio |CS |22 |
===========================================================================================
//.................
//:AND OR AND :
//.................
[33]: select * from student where age <30 and major=CS or major = Physics and lname = Jackson
===========================================================================================
| # |fname |lname |major |age |
===========================================================================================
| 0 |Flo |Yao |CS |20 |
| 1 |Anna Grace |Del Rio |CS |22 |
===========================================================================================
//.................
//:OR AND OR :
//.................
[34]: select * from student where lname = Yang or major = CS and age < 23 or lname = Jackson
===========================================================================================
| # |fname |lname |major |age |
===========================================================================================
| 0 |Flo |Yao |CS |20 |
| 1 |Flo |Jackson |Math |21 |
| 2 |Anna Grace |Del Rio |CS |22 |
===========================================================================================
> quit
Press <RETURN> to close this window...
*/
// OUTPUT V (Final SQL BATCH RUN):
/*
------ Currently Managed SQL Tables: ------
-------------------------------------------
> batch "_!select"
[0]: batch "_!select"
//****************************************************************************
// CREATE TABLES AND INSERT RECORDS
//****************************************************************************
[1]: make table employee fields last, first, dep, salary, year
------ Currently Managed SQL Tables: ------
employee
-------------------------------------------
[2]: insert into employee values Blow, Joe, CS, 100000, 2018
[3]: insert into employee values Blow, JoAnn, Physics, 200000, 2016
[4]: insert into employee values Johnson, Jack, HR, 150000, 2014
[5]: insert into employee values Johnson, "Jimmy", Chemistry, 140000, 2018
[6]: insert into employee values Yao, Jimmy, Math, 145000, 2014
[7]: insert into employee values "Yao", Flo, CS, 147000, 2012
[8]: insert into employee values Yang, Bo, CS, 160000, 2013
[9]: insert into employee values Jackson, "Flo", Math, 165000, 2017
[10]: insert into employee values Jackson, Bo, Chemistry, 130000, 2011
[11]: insert into employee values "Jackson", Billy, Math, 170000, 2017
[12]: insert into employee values Johnson, "Mary Ann", Math, 165000, 2014
[13]: insert into employee values Johnson, "Billy Bob", Physics, 142000, 2014
[14]: insert into employee values Johnson, Billy, "Phys Ed", 102000, 2014
[15]: insert into employee values "Van Gogh", Vincent, Art, 240000, 2015
[16]: insert into employee values "Van Gogh", Vincent, CS, 245000, 2015
[17]: insert into employee values "Van Gogh", "Jim Bob", "Phys Ed", 230000, 2010
[18]: select * from employee
================================================================================================================
| # |last |first |dep |salary |year |
================================================================================================================
| 0 |Blow |Joe |CS |100000 |2018 |
| 1 |Blow |JoAnn |Physics |200000 |2016 |
| 2 |Johnson |Jack |HR |150000 |2014 |
| 3 |Johnson |Jimmy |Chemistry |140000 |2018 |
| 4 |Yao |Jimmy |Math |145000 |2014 |
| 5 |Yao |Flo |CS |147000 |2012 |
| 6 |Yang |Bo |CS |160000 |2013 |
| 7 |Jackson |Flo |Math |165000 |2017 |
| 8 |Jackson |Bo |Chemistry |130000 |2011 |
| 9 |Jackson |Billy |Math |170000 |2017 |
| 10 |Johnson |Mary Ann |Math |165000 |2014 |
| 11 |Johnson |Billy Bob |Physics |142000 |2014 |
| 12 |Johnson |Billy |Phys Ed |102000 |2014 |
| 13 |Van Gogh |Vincent |Art |240000 |2015 |
| 14 |Van Gogh |Vincent |CS |245000 |2015 |
| 15 |Van Gogh |Jim Bob |Phys Ed |230000 |2010 |
================================================================================================================
[19]: make table student fields fname, lname, major, age, company
------ Currently Managed SQL Tables: ------
employee
student
-------------------------------------------
[20]: insert into student values Flo, Yao, CS, 20, Google
[21]: insert into student values Bo, Yang, CS, 28, Microsoft
[22]: insert into student values "Sammuel L.", Jackson, CS, 40, Uber
[23]: insert into student values "Flo", "Jackson", Math, 21, Google
[24]: insert into student values "Greg", "Pearson", Physics, 20, Amazon
[25]: insert into student values "Jim Bob", Smith, Math, 23, Verizon
[26]: insert into student values Calvin, Woo, Physics, 22, Uber
[27]: insert into student values "Anna Grace", "Del Rio", CS, 22, USAF
[28]: insert into student values "Teresa Mae", Gowers, Chemistry, 22, Verizon
[29]: insert into student values Alex, Smith, "Gender Studies", 53, Amazon
[30]: select * from student
================================================================================================================
| # |fname |lname |major |age |company |
================================================================================================================
| 0 |Flo |Yao |CS |20 |Google |
| 1 |Bo |Yang |CS |28 |Microsoft |
| 2 |Sammuel L. |Jackson |CS |40 |Uber |
| 3 |Flo |Jackson |Math |21 |Google |
| 4 |Greg |Pearson |Physics |20 |Amazon |
| 5 |Jim Bob |Smith |Math |23 |Verizon |
| 6 |Calvin |Woo |Physics |22 |Uber |
| 7 |Anna Grace |Del Rio |CS |22 |USAF |
| 8 |Teresa Mae |Gowers |Chemistry |22 |Verizon |
| 9 |Alex |Smith |Gender Studies |53 |Amazon |
================================================================================================================
//****************************************************************************
// SIMPLE SELECT:
//****************************************************************************
[31]: select * from student
================================================================================================================
| # |fname |lname |major |age |company |
================================================================================================================
| 0 |Flo |Yao |CS |20 |Google |
| 1 |Bo |Yang |CS |28 |Microsoft |
| 2 |Sammuel L. |Jackson |CS |40 |Uber |
| 3 |Flo |Jackson |Math |21 |Google |
| 4 |Greg |Pearson |Physics |20 |Amazon |
| 5 |Jim Bob |Smith |Math |23 |Verizon |
| 6 |Calvin |Woo |Physics |22 |Uber |
| 7 |Anna Grace |Del Rio |CS |22 |USAF |
| 8 |Teresa Mae |Gowers |Chemistry |22 |Verizon |
| 9 |Alex |Smith |Gender Studies |53 |Amazon |
================================================================================================================
//------- simple strings -------------------
[32]: select * from student where lname = Jackson
================================================================================================================
| # |fname |lname |major |age |company |
================================================================================================================
| 0 |Sammuel L. |Jackson |CS |40 |Uber |
| 1 |Flo |Jackson |Math |21 |Google |
================================================================================================================
[33]: select * from student where major = CS
================================================================================================================
| # |fname |lname |major |age |company |
================================================================================================================
| 0 |Flo |Yao |CS |20 |Google |
| 1 |Bo |Yang |CS |28 |Microsoft |
| 2 |Sammuel L. |Jackson |CS |40 |Uber |
| 3 |Anna Grace |Del Rio |CS |22 |USAF |
================================================================================================================
[34]: select * from student where company = Uber
================================================================================================================
| # |fname |lname |major |age |company |
================================================================================================================
| 0 |Sammuel L. |Jackson |CS |40 |Uber |
| 1 |Calvin |Woo |Physics |22 |Uber |
================================================================================================================
//----- quoted strings ---------------------
[35]: select * from student where lname = "Del Rio"
================================================================================================================
| # |fname |lname |major |age |company |
================================================================================================================
| 0 |Anna Grace |Del Rio |CS |22 |USAF |
================================================================================================================
[36]: select * from student where fname = "Jim Bob"
================================================================================================================
| # |fname |lname |major |age |company |
================================================================================================================
| 0 |Jim Bob |Smith |Math |23 |Verizon |
================================================================================================================
[37]: select * from student where fname = "Anna Grace"
================================================================================================================
| # |fname |lname |major |age |company |
================================================================================================================
| 0 |Anna Grace |Del Rio |CS |22 |USAF |
================================================================================================================
[38]: select * from student where fname = "Teresa Mae"
================================================================================================================
| # |fname |lname |major |age |company |
================================================================================================================
| 0 |Teresa Mae |Gowers |Chemistry |22 |Verizon |
================================================================================================================
//-------- non-existing string ------------------
[39]: select * from student where lname = "Does Not Exist"
================================================================================================================
| # |fname |lname |major |age |company |
================================================================================================================
| EMPTY |
================================================================================================================
//****************************************************************************
// RELATIONAL OPERATORS:
//****************************************************************************
//.................
//:Greater Than :
//.................
[40]: select * from student where lname > Yang
================================================================================================================
| # |fname |lname |major |age |company |
================================================================================================================
| 0 |Flo |Yao |CS |20 |Google |
================================================================================================================
[41]: select * from student where major > Math
================================================================================================================
| # |fname |lname |major |age |company |
================================================================================================================
| 0 |Greg |Pearson |Physics |20 |Amazon |
| 1 |Calvin |Woo |Physics |22 |Uber |
================================================================================================================
[42]: select * from student where fname > "Sammuel L."
================================================================================================================
| # |fname |lname |major |age |company |
================================================================================================================
| 0 |Teresa Mae |Gowers |Chemistry |22 |Verizon |
================================================================================================================
[43]: select * from employee where salary > 200000
================================================================================================================
| # |last |first |dep |salary |year |
================================================================================================================
| 0 |Van Gogh |Jim Bob |Phys Ed |230000 |2010 |
| 1 |Van Gogh |Vincent |Art |240000 |2015 |
| 2 |Van Gogh |Vincent |CS |245000 |2015 |
================================================================================================================
[44]: select * from employee where dep > Chemistry
================================================================================================================
| # |last |first |dep |salary |year |
================================================================================================================
| 0 |Johnson |Jack |HR |150000 |2014 |
| 1 |Yao |Jimmy |Math |145000 |2014 |
| 2 |Jackson |Flo |Math |165000 |2017 |
| 3 |Jackson |Billy |Math |170000 |2017 |
| 4 |Johnson |Mary Ann |Math |165000 |2014 |
| 5 |Johnson |Billy |Phys Ed |102000 |2014 |
| 6 |Van Gogh |Jim Bob |Phys Ed |230000 |2010 |
| 7 |Blow |JoAnn |Physics |200000 |2016 |
| 8 |Johnson |Billy Bob |Physics |142000 |2014 |
================================================================================================================
[45]: select * from employee where last > Jackson
================================================================================================================
| # |last |first |dep |salary |year |
================================================================================================================
| 0 |Johnson |Jack |HR |150000 |2014 |
| 1 |Johnson |Jimmy |Chemistry |140000 |2018 |
| 2 |Johnson |Mary Ann |Math |165000 |2014 |
| 3 |Johnson |Billy Bob |Physics |142000 |2014 |
| 4 |Johnson |Billy |Phys Ed |102000 |2014 |
| 5 |Van Gogh |Vincent |Art |240000 |2015 |
| 6 |Van Gogh |Vincent |CS |245000 |2015 |
| 7 |Van Gogh |Jim Bob |Phys Ed |230000 |2010 |
| 8 |Yang |Bo |CS |160000 |2013 |
| 9 |Yao |Jimmy |Math |145000 |2014 |
| 10 |Yao |Flo |CS |147000 |2012 |
================================================================================================================
[46]: select * from employee where first > "Billy Bob"
================================================================================================================
| # |last |first |dep |salary |year |
================================================================================================================
| 0 |Yang |Bo |CS |160000 |2013 |
| 1 |Jackson |Bo |Chemistry |130000 |2011 |
| 2 |Yao |Flo |CS |147000 |2012 |
| 3 |Jackson |Flo |Math |165000 |2017 |
| 4 |Johnson |Jack |HR |150000 |2014 |
| 5 |Van Gogh |Jim Bob |Phys Ed |230000 |2010 |
| 6 |Johnson |Jimmy |Chemistry |140000 |2018 |
| 7 |Yao |Jimmy |Math |145000 |2014 |
| 8 |Blow |JoAnn |Physics |200000 |2016 |
| 9 |Blow |Joe |CS |100000 |2018 |
| 10 |Johnson |Mary Ann |Math |165000 |2014 |
| 11 |Van Gogh |Vincent |Art |240000 |2015 |
| 12 |Van Gogh |Vincent |CS |245000 |2015 |
================================================================================================================
//. . . . . . . . . . . . . (Greater Than: Non-existing) . . . . . . . . . . . . . . . . . . . . .
[47]: select * from student where age > 50
================================================================================================================
| # |fname |lname |major |age |company |
================================================================================================================
| 0 |Alex |Smith |Gender Studies |53 |Amazon |
================================================================================================================
[48]: select * from student where age > 35
================================================================================================================
| # |fname |lname |major |age |company |
================================================================================================================
| 0 |Sammuel L. |Jackson |CS |40 |Uber |
| 1 |Alex |Smith |Gender Studies |53 |Amazon |
================================================================================================================
[49]: select * from student where fname > T
================================================================================================================
| # |fname |lname |major |age |company |
================================================================================================================
| 0 |Teresa Mae |Gowers |Chemistry |22 |Verizon |
================================================================================================================
[50]: select * from employee where salary > 130000
================================================================================================================
| # |last |first |dep |salary |year |
================================================================================================================
| 0 |Johnson |Jimmy |Chemistry |140000 |2018 |
| 1 |Johnson |Billy Bob |Physics |142000 |2014 |
| 2 |Yao |Jimmy |Math |145000 |2014 |
| 3 |Yao |Flo |CS |147000 |2012 |
| 4 |Johnson |Jack |HR |150000 |2014 |
| 5 |Yang |Bo |CS |160000 |2013 |
| 6 |Jackson |Flo |Math |165000 |2017 |
| 7 |Johnson |Mary Ann |Math |165000 |2014 |
| 8 |Jackson |Billy |Math |170000 |2017 |
| 9 |Blow |JoAnn |Physics |200000 |2016 |
| 10 |Van Gogh |Jim Bob |Phys Ed |230000 |2010 |
| 11 |Van Gogh |Vincent |Art |240000 |2015 |
| 12 |Van Gogh |Vincent |CS |245000 |2015 |
================================================================================================================
[51]: select * from employee where year > 2009
================================================================================================================
| # |last |first |dep |salary |year |
================================================================================================================
| 0 |Van Gogh |Jim Bob |Phys Ed |230000 |2010 |
| 1 |Jackson |Bo |Chemistry |130000 |2011 |
| 2 |Yao |Flo |CS |147000 |2012 |
| 3 |Yang |Bo |CS |160000 |2013 |
| 4 |Johnson |Jack |HR |150000 |2014 |
| 5 |Yao |Jimmy |Math |145000 |2014 |
| 6 |Johnson |Mary Ann |Math |165000 |2014 |
| 7 |Johnson |Billy Bob |Physics |142000 |2014 |
| 8 |Johnson |Billy |Phys Ed |102000 |2014 |
| 9 |Van Gogh |Vincent |Art |240000 |2015 |
| 10 |Van Gogh |Vincent |CS |245000 |2015 |
| 11 |Blow |JoAnn |Physics |200000 |2016 |
| 12 |Jackson |Flo |Math |165000 |2017 |
| 13 |Jackson |Billy |Math |170000 |2017 |
| 14 |Blow |Joe |CS |100000 |2018 |
| 15 |Johnson |Jimmy |Chemistry |140000 |2018 |
================================================================================================================
//. . . . . . . . . . . . . (Greater than: last item) . . . . . . . . . . . . . . . . . .
[52]: select * from student where age > 53
================================================================================================================
| # |fname |lname |major |age |company |
================================================================================================================
| EMPTY |
================================================================================================================
[53]: select * from student where lname > Yao
================================================================================================================
| # |fname |lname |major |age |company |
================================================================================================================
| EMPTY |
================================================================================================================
[54]: select * from student where fname > "Teresa Mae"
================================================================================================================
| # |fname |lname |major |age |company |
================================================================================================================
| EMPTY |
================================================================================================================
[55]: select * from employee where last > "Van Gogh"
================================================================================================================
| # |last |first |dep |salary |year |
================================================================================================================
| 0 |Yang |Bo |CS |160000 |2013 |
| 1 |Yao |Jimmy |Math |145000 |2014 |
| 2 |Yao |Flo |CS |147000 |2012 |
================================================================================================================
[56]: select * from employee where first > Vincent
================================================================================================================
| # |last |first |dep |salary |year |
================================================================================================================
| EMPTY |
================================================================================================================
[57]: select * from employee where salary > 260000
================================================================================================================
| # |last |first |dep |salary |year |
================================================================================================================
| EMPTY |
================================================================================================================
//. . . . . . . . . . . . . (Greater Than: Passed last item) . . . . . . . . . . . . . . . . . . . . .
[58]: select * from student where age > 54
================================================================================================================
| # |fname |lname |major |age |company |
================================================================================================================
| EMPTY |
================================================================================================================
[59]: select * from student where lname > Zoolander
================================================================================================================