Skip to content

Commit 762198e

Browse files
authored
Add files via upload
add file
1 parent 116bda4 commit 762198e

File tree

4 files changed

+85
-0
lines changed

4 files changed

+85
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// select
2+
The SELECT statement is used to select data from a database and retrieve the information.
3+
1. SELECT ALL Columns from the table_name;
4+
Syntax: SELECT * FROM tbale_name;
5+
ex:select * from student_reg;
6+
+------+---------+---------+------------+-----------+
7+
| s_id | name | address | dob | fees |
8+
+------+---------+---------+------------+-----------+
9+
| 101 | RAM | KTM | 1998-12-15 | 1000.23 |
10+
| 102 | SITA | KTM | 2001-10-11 | 200000.12 |
11+
| 103 | HARI | PKR | 2001-01-12 | 10000.52 |
12+
| 104 | BIMAl | KTM | NULL | 1001.23 |
13+
| 105 | KAMAL | PKR | 1956-12-12 | 100000.12 |
14+
| 106 | SITA KC | PKR | 1998-02-02 | 20000.12 |
15+
+------+---------+---------+------------+-----------+
16+
2. Select Particular columns from the table
17+
Syntax: select column_name1,column_name2... from table;
18+
ex: select name,dob from student_reg;
19+
+---------+------------+
20+
| name | dob |
21+
+---------+------------+
22+
| RAM | 1998-12-15 |
23+
| SITA | 2001-10-11 |
24+
| HARI | 2001-01-12 |
25+
| BIMAl | NULL |
26+
| KAMAL | 1956-12-12 |
27+
| SITA KC | 1998-02-02 |
28+
+---------+------------+

SELECT with LIMIT in SQL.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
//SELECT with LIMIT in SQL
2+
SELECT LIMIT is used to specify some number of records to display
3+
syntax: SELECT column_name1,column_name2 From table_name LIMIT recorde_number;
4+
ex: SELECT * FROM student_reg LIMIT 4;
5+
+------+-------+---------+------------+-----------+
6+
| s_id | name | address | dob | fees |
7+
+------+-------+---------+------------+-----------+
8+
| 101 | RAM | KTM | 1998-12-15 | 1000.23 |
9+
| 102 | SITA | KTM | 2001-10-11 | 200000.12 |
10+
| 103 | HARI | PKR | 2001-01-12 | 10000.52 |
11+
| 104 | BIMAl | KTM | NULL | 1001.23 |
12+
+------+-------+---------+------------+-----------+

Single Quotes problem in SQL.txt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//Single Quotes problem in SQL
2+
INSERT INTO table_name(id,c_name,address) VALUES(1,'un'i testing','np');
3+
There are two way to solve this problem
4+
1.-> Use backslash
5+
ex:'un'\i testing'
6+
2.-> Use two time single Quotes
7+
ex: 'un''i testing'
8+
9+
ex: insert into student (name,roll,address)VALUES('U\'I Testing',101,'Ktm
10+
');
11+
OutPut:
12+
select * from student;
13+
+-------------+------+---------+
14+
| name | roll | address |
15+
+-------------+------+---------+
16+
| U'I Testing | 101 | Ktm |
17+
+-------------+------+---------+
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// WHERE
2+
-> is used to search for a specific data;
3+
1. Specifi data from all column
4+
Syntax: SELECT * FROM table_name WHERE column_name operators 'value';
5+
ex: SELECT * FROM student_reg WHERE s_id='102';
6+
+------+------+---------+------------+-----------+
7+
| s_id | name | address | dob | fees |
8+
+------+------+---------+------------+-----------+
9+
| 102 | SITA | KTM | 2001-10-11 | 200000.12 |
10+
+------+------+---------+------------+-----------+
11+
Note: Value can be text or numeric. if it is text then we have to put single quotes.
12+
13+
14+
SQL Comparison Operators
15+
Operator Description Example
16+
= Equal to
17+
> Greater than
18+
< Less than
19+
>= Greater than or equal to
20+
<= Less than or equal to
21+
<> Not equal to
22+
<> or != Not equal
23+
BETWEEN Between an inclusive range
24+
LIKE search for a pattern
25+
In To specifY MULTIPLE POSSIBLE VALUE OF A COLUMN
26+
27+
2. specific data from specific column
28+
Syntax: SELECT column_name From table_name WHERE column_name operator 'value';

0 commit comments

Comments
 (0)