-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDelete Records in Table in SQL.txt
More file actions
26 lines (22 loc) · 1.19 KB
/
Delete Records in Table in SQL.txt
File metadata and controls
26 lines (22 loc) · 1.19 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
// DELETE Records in Table
The DELETE statement is used to delete records in a table.
1. DELETE a specific Record
Syntax: DELETE FROM table_name WHERE some_column = some_value;
ex: DELETE FROM student_reg WHERE s_id = 105 AND name ='KAMAL';
:- select * from student_reg;
+------+---------+---------+------------+-----------+------+--------+-------+
| s_id | name | address | dob | fees | id | result | marks |
+------+---------+---------+------------+-----------+------+--------+-------+
| 101 | RAM | KTM | 1998-12-15 | 100000.23 | 1001 | SECOND | 300 |
| 102 | SITA | KTM | 2001-10-11 | 200000.12 | NULL | SECOND | 400 |
| 103 | HARI | PKR | 2001-01-12 | 10000.52 | NULL | FIRST | 450 |
| 104 | BIMAl | KTM | NULL | 100200.00 | NULL | THIRD | 250 |
| 106 | SITA KC | PKR | 1998-02-02 | 20000.12 | NULL | SECOND | 340 |
+------+---------+---------+------------+-----------+------+--------+-------+
.Note :- WHERE is necessary otherqwise all records will be delete.
2. DELETE ALL Records
-> syntax: DELETE FROM table_name;
OR//
DELETE * FROM table_name;
ex: DELETE FROM table_name;
. Note : We cannot undo this