Академический Документы
Профессиональный Документы
Культура Документы
(BM Shukla)
1.
~1~
6.
7.
INSERT Syntax
INSERT inserts new rows into an existing table
A) To Insert data in all columns of a table.
INSERT INTO TableName values ()
Example: Insert into StudentDetail values(1,Ravi,WoodBine),;
B) To Insert data in a column(s) of the table.
INSERT INTO TableName (ColName1, ColName2,..) values(val1,val2,..)
Example: Insert into StudentDetail (StudentId, StudentName) values(2,Shyaam),;
C) To Insert data into a table from another table.
INSERT INTO TableName (ColName1,ColName2) select ColName1,ColName2 From TableName2.
Example: Insert into StudentName (StudentName) select Name from NameLog;
8.
SELECT Syntax
SELECT is used to retrieve rows selected from one or more tables
D) To Select all data from the table
SELECT * FROM TABLENAME;
Example: Select * from StudentDetail;
E) To Select data of a particular Column from the table
SELECT ColumnName FROM TABLENAME;
Example: Select StudentName from StudentDetail;
F) To Select data based on a condition
SELECT * FROM TABLENAME where Condition;
Example: Select StudentName from StudentDetail where StudentId=2;
G) To Select limited number of Records at a time
SELECT * FROM TABLENAME LIMIT no.of records
Example: Select StudentName from StudentDetail LIMIT 10
9.
UPDATE Syntax
UPDATE statement updates columns of existing rows in TableName with new values. The SET clause
indicates which columns to modify and the values they should be given. The WHERE clause, if given,
specifies the conditions that identify which rows to update. With no WHERE clause, all rows are updated. A)
To Update data based on a condition
UPDATE TableName SET ColumnName=value where condition;
Example: UPDATE StudentDetail SET StudentName=Rohan where StudentId=1;
B) To Update all records simultaneously
UPDATE TableName SET ColumnName=value where condition
Example: UPDATE StudentDetail SET School=Wendy High School;
~2~
{Note: For primary key and Unique Key Indices are created by default}
TableName set
FieldName=CONCAT(UPPER(SUBSTRING(FieldName,1,1)),LOWER(SUBSTRING(FIELD
NAME,2)));