-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path04 MySQL Operators.sql
More file actions
60 lines (32 loc) · 1.39 KB
/
04 MySQL Operators.sql
File metadata and controls
60 lines (32 loc) · 1.39 KB
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
use sample;
create table users (id int primary key auto_increment, name text, age int);
insert into users (name, age) values ("vicky", 31);
select * from users;
# how many rows here
select count(*) from users;
select * from users where id = 3;
select * from users where age = 29;
# age less than 30
select * from users where age < 30;
# age greater than 30
select * from users where age > 30;
#age less than to equal to 30
select * from users where age <= 30;
select * from users where age >= 30;
# let's say one name is equal to thiru
INSERT INTO `sample`.`users` (`id`, `name`, `age`) VALUES ('9', 'vicky', '32');
select * from users where name ="vicky";
#not equal to vicky
select * from users where name !="vicky";
# is operator using
select * from users where name is not null;
#like operator
select * from users where name LIKE "%ku%";
#--- LOGICAL OPERATORSS--##
select * from users where age > 30 and name ="vicky";
select * from users where age < 30 and id >= 5 and name like "% a %" and name is not null;
select * from users where (age < 20 or age > 40 )and name ="kumar";
# or vs xor
select * from users where age <30 or age <30;
# xor apply
select * from users where age <30 xor age <30;