You are on page 1of 2

SQL Queries with Syntax and Examples for MS Access

Structured Query Language: *Standard*

a) To Manipulate and manage Data (Insert, Update/Modify, Delete)


b) To Define Data (Create Tables etc)
c) SELECT

1) SELECT: Command to Fetch Data (to show data)


SYNTAX: SELECT <List of Fields> From <Table-Name> [where <Condition>] ;
EXAMPLE:
a) SELECT * FROM tble_Student;
b) SELECT C-NAME, C-AGE, RELATIONSHIP FROM tble_Student;
c) SELECT * FROM tble_Student WHERE AGE>20;

Formatting:
SELECT *
FROM TBLE_STUDENT
WHERE AGE >20;

SELECT *
FROM TBLE_STUDENT
WHERE [AGE] >20;

SELECT C_NAME, C_AGE, RELATIONSHIP


FROM tble_Student
Where (AGE>20 or Age = 20);

2) DELETE: To Delete Records from a table


SYNTAX: DELETE FROM <TABLE-NAME> [WHERE <Condition>];
EXAMPLES:
a) Delete from table_Contact; (All Records)
b) Delete from table Contact Where Age >20;
c) DELETE FROM TABLE_CONTACT WHERE (Age =20 or Age > 20);
d) DELETE FROM TABLE_CONTACT WHERE Age > 20 and City = “ISB”;
AGE^20
Formatting:
DELETE
FROM TABLE_CONTACT
WHERE Age > 20;
DELETE
FROM TABLE_CONTACT
WHERE Age > 20 and City = “ISB”;

3) INSERT: To Insert Records into table

Insert Into <Table-Name>


(Fieldname1, Fieldname2, Fieldname3,..)
Values
(value1, value2, value3,..);

4) CREATE TABLE: (To create a Table)


SYNTAX: CREATE TABLE <TABLE-NAME> (Field 1 data type, Field 2 Data Type…);
Example: CREAT TABLE TBLE_STUDENT (Reg-No Text, Name Text);
Formatting:
CREATE TABLE TBLE_STUDENT
(Reg-No Text Constraint abc Primary Key,
Name Text
Class Text);

CREATE TABLE TBLE_STUDENT


(Reg-No Text Constraint Tble_Student_ABC-PK Primary Key,
Name Text
Class Text);

You might also like