Skip to content

Commit 5caa5b0

Browse files
authored
Add files via upload
add mysqli file
1 parent 6842095 commit 5caa5b0

6 files changed

+175
-0
lines changed

BETWEEN with IN in SQL.txt

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// BETWEEN with IN
2+
Syntax: SELET * FROM table_name WHERE (column_name BETWEEN value1 AND value2)AND column_name IN (value1 , value2);
3+
ex: SELECT * FROM student_reg WHERE (fees BETWEEN 1000 AND 20000) AND add
4+
ress IN ('KTM','PRK');
5+
+------+-------+---------+------------+---------+
6+
| s_id | name | address | dob | fees |
7+
+------+-------+---------+------------+---------+
8+
| 101 | RAM | KTM | 1998-12-15 | 1000.23 |
9+
| 104 | BIMAl | KTM | NULL | 1001.23 |
10+
+------+-------+---------+------------+---------+
11+
12+
// OR
13+
ex: SELECT * FROM student_reg WHERE (fees BETWEEN 1000 AND 20000) OR addr
14+
ess IN ('KTM','PRK');
15+
+------+-------+---------+------------+-----------+
16+
| s_id | name | address | dob | fees |
17+
+------+-------+---------+------------+-----------+
18+
| 101 | RAM | KTM | 1998-12-15 | 1000.23 |
19+
| 102 | SITA | KTM | 2001-10-11 | 200000.12 |
20+
| 103 | HARI | PKR | 2001-01-12 | 10000.52 |
21+
| 104 | BIMAl | KTM | NULL | 1001.23 |
22+
+------+-------+---------+------------+-----------+

BETWEEN with NOT IN in SQL.txt

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// BETWEEN with NOT IN
2+
syntax: SELCET * FROM table_name WHERE (column_name BETWEEn value1 AND value2) AND
3+
NOT column_name IN (value1, value2)
4+
5+
Ex:select * from student_reg WHERE (fees BETWEEN 1000 AND 20000) AND NOT s_id IN (101,105);
6+
+------+-------+---------+------------+----------+
7+
| s_id | name | address | dob | fees |
8+
+------+-------+---------+------------+----------+
9+
| 103 | HARI | PKR | 2001-01-12 | 10000.52 |
10+
| 104 | BIMAl | KTM | NULL | 1001.23 |
11+
+------+-------+---------+------------+----------+

LIKE with % WildCard in SQl.txt

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
// LIKE with % WildCard in SQL
2+
-> The Like operator is used to search for a specified pattern in a column.
3+
syntax: SELECT * FROM table_name WHERE column_name LIKE 'pattern';
4+
5+
// Wild cards
6+
-> Wild cards are used to search for data within a table. These characters are used with thr LIKE operator.
7+
% -> zero or more characters
8+
_ -> One single character
9+
[charlist] -> Sets and ranges of characters to match
10+
[^charlist] or [!charlist] -> Matches only a character NOT specified within the brackets
11+
12+
1. % -> zero or more characters
13+
'hello%' - all starting with hello Ex: hello testing
14+
ex: SELECT * FROM student_reg WHERE name LIKE 'bi%';
15+
+------+-------+---------+------+---------+
16+
| s_id | name | address | dob | fees |
17+
+------+-------+---------+------+---------+
18+
| 104 | BIMAl | KTM | NULL | 1001.23 |
19+
+------+-------+---------+------+---------+
20+
21+
'%testing' - All ending with testing Ex: hello testing
22+
ex:SELECT * FROM student_reg WHERE name LIKE '%i';
23+
+------+------+---------+------------+----------+
24+
| s_id | name | address | dob | fees |
25+
+------+------+---------+------------+----------+
26+
| 103 | HARI | PKR | 2001-01-12 | 10000.52 |
27+
+------+------+---------+------------+----------+
28+
29+
'%in%' - all containing with in ex: hello testing
30+
SELECT * FROM student_reg WHERE name LIKE '%ma%';
31+
+------+-------+---------+------------+-----------+
32+
| s_id | name | address | dob | fees |
33+
+------+-------+---------+------------+-----------+
34+
| 104 | BIMAl | KTM | NULL | 1001.23 |
35+
| 105 | KAMAL | PKR | 1956-12-12 | 100000.12 |
36+
+------+-------+---------+------------+-----------+
37+
38+
2. - one single character
39+
'testing_ -> '-starting with show then any character Ex testing
40+
Ex: SELECT * FROM student_reg WHERE s_id LIKE '10_';
41+
+------+---------+---------+------------+-----------+
42+
| s_id | name | address | dob | fees |
43+
+------+---------+---------+------------+-----------+
44+
| 101 | RAM | KTM | 1998-12-15 | 1000.23 |
45+
| 102 | SITA | KTM | 2001-10-11 | 200000.12 |
46+
| 103 | HARI | PKR | 2001-01-12 | 10000.52 |
47+
| 104 | BIMAl | KTM | NULL | 1001.23 |
48+
| 105 | KAMAL | PKR | 1956-12-12 | 100000.12 |
49+
| 106 | SITA KC | PKR | 1998-02-02 | 20000.12 |
50+
+------+---------+---------+------------+-----------+
51+
'_tin' -> ant charaxter the tin. Ex testing
52+
ex:SELECT * FROM student_reg WHERE s_id LIKE '_04';
53+
+------+-------+---------+------+---------+
54+
| s_id | name | address | dob | fees |
55+
+------+-------+---------+------+---------+
56+
| 104 | BIMAl | KTM | NULL | 1001.23 |
57+
+------+-------+---------+------+---------+
58+
't_s_g -> t then any character then s then any character, then g ex: testing
59+
ex: SELECT * FROM student_reg WHERE s_id LIKE '1_3';
60+
+------+------+---------+------------+----------+
61+
| s_id | name | address | dob | fees |
62+
+------+------+---------+------------+----------+
63+
| 103 | HARI | PKR | 2001-01-12 | 10000.52 |
64+
+------+------+---------+------------+----------+

NOT Between Number inSQL.txt

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// NOT BETWEEN NUMBER
2+
To display the data which is not in the range.
3+
1. Not BETWEEN NUMBER
4+
syntax: SELECT * FROM table_Name WHERE column_name NOT BETWEEN value1 AND value2;
5+
SELECT * FROM student_reg WHERE s_id NOT BETWEEN 102 AND 104;
6+
+------+---------+---------+------------+-----------+
7+
| s_id | name | address | dob | fees |
8+
+------+---------+---------+------------+-----------+
9+
| 101 | RAM | KTM | 1998-12-15 | 1000.23 |
10+
| 105 | KAMAL | PKR | 1956-12-12 | 100000.12 |
11+
| 106 | SITA KC | PKR | 1998-02-02 | 20000.12 |
12+
+------+---------+---------+------------+-----------+
13+
14+
//2. NOT BETWEEN Text
15+
ex: SELECT * FROM student_reg WHERE name NOT BETWEEN 'B' AND 'H';
16+
+------+---------+---------+------------+-----------+
17+
| s_id | name | address | dob | fees |
18+
+------+---------+---------+------------+-----------+
19+
| 101 | RAM | KTM | 1998-12-15 | 1000.23 |
20+
| 102 | SITA | KTM | 2001-10-11 | 200000.12 |
21+
| 103 | HARI | PKR | 2001-01-12 | 10000.52 |
22+
| 105 | KAMAL | PKR | 1956-12-12 | 100000.12 |
23+
| 106 | SITA KC | PKR | 1998-02-02 | 20000.12 |
24+
+------+---------+---------+------------+-----------+
25+
26+
27+
// 3. NOT BETWEEN DATE
28+
ex: SELECT * FROM student_reg WHERE dob NOT BETWEEN '1998-12-12' AND '2001-01-12';
29+
+------+---------+---------+------------+-----------+
30+
| s_id | name | address | dob | fees |
31+
+------+---------+---------+------------+-----------+
32+
| 102 | SITA | KTM | 2001-10-11 | 200000.12 |
33+
| 105 | KAMAL | PKR | 1956-12-12 | 100000.12 |
34+
| 106 | SITA KC | PKR | 1998-02-02 | 20000.12 |
35+
+------+---------+---------+------------+-----------+

NOT LIKE in SQL.txt

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Not Like
2+
syntax : SELECT * FROM table_name WHERE column_name NOT LIKE 'pattern';
3+
ex: SELECT * FROM student_reg WHERE name NOT LIKE '%h%';
4+
+------+---------+---------+------------+-----------+
5+
| s_id | name | address | dob | fees |
6+
+------+---------+---------+------------+-----------+
7+
| 101 | RAM | KTM | 1998-12-15 | 1000.23 |
8+
| 102 | SITA | KTM | 2001-10-11 | 200000.12 |
9+
| 104 | BIMAl | KTM | NULL | 1001.23 |
10+
| 105 | KAMAL | PKR | 1956-12-12 | 100000.12 |
11+
| 106 | SITA KC | PKR | 1998-02-02 | 20000.12 |
12+
+------+---------+---------+------------+-----------+

ORDER BY Descending order in SQL.txt

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// ORDER BY descending order
2+
This is used to sort the recorde.
3+
ASC -> It sort in ascending order (by default)
4+
DESC -> It sort in descending order.
5+
6+
1. Sort in descending order
7+
Syntax: SELECT * FROM student_reg ORDER BY column_name DESC;
8+
ex: select * from student_reg ORDER BY name DESC;
9+
+------+---------+---------+------------+-----------+
10+
| s_id | name | address | dob | fees |
11+
+------+---------+---------+------------+-----------+
12+
| 106 | SITA KC | PKR | 1998-02-02 | 20000.12 |
13+
| 102 | SITA | KTM | 2001-10-11 | 200000.12 |
14+
| 101 | RAM | KTM | 1998-12-15 | 1000.23 |
15+
| 105 | KAMAL | PKR | 1956-12-12 | 100000.12 |
16+
| 103 | HARI | PKR | 2001-01-12 | 10000.52 |
17+
| 104 | BIMAl | KTM | NULL | 1001.23 |
18+
+------+---------+---------+------------+-----------+
19+
20+
// ORDER BY Asecending
21+
ex: select * from student_reg ORDER BY name ASC;
22+
+------+---------+---------+------------+-----------+
23+
| s_id | name | address | dob | fees |
24+
+------+---------+---------+------------+-----------+
25+
| 104 | BIMAl | KTM | NULL | 1001.23 |
26+
| 103 | HARI | PKR | 2001-01-12 | 10000.52 |
27+
| 105 | KAMAL | PKR | 1956-12-12 | 100000.12 |
28+
| 101 | RAM | KTM | 1998-12-15 | 1000.23 |
29+
| 102 | SITA | KTM | 2001-10-11 | 200000.12 |
30+
| 106 | SITA KC | PKR | 1998-02-02 | 20000.12 |
31+
+------+---------+---------+------------+-----------+

0 commit comments

Comments
 (0)