SQL SelectInsertUpdateDeleteSyntax

Jump to: navigation, search

SQL Syntax

INSERT

INSERT into temp_user 
( fistName, lastName, recCreationDate )
VALUES
('jeff', 'meyers', '3/24/03')

SELECT

/* Select everyting from the temp_user table */
SELECT * from temp_user  
		 
/* Select userID,firtName,lastName from the temp_user table */
SELECT userID,firtName,lastName from temp_user
		 
/* Select userID,firtName,lastName from the temp_user table 
		 	where firstName is jeff*/
SELECT userID,firtName,lastName from temp_user where firstName = 'jeff'
		 
/* Select userID,firtName,lastName from the temp_user table 
		 	where firstName is jeff then sorts by lastName*/
SELECT userID,firtName,lastName from temp_user where firstName = 'jeff' order by LastName
		 
/* Select userID,firtName,lastName from the temp_user table 
		 	where firstName is jeff then sorts by lastName in reverse order*/
SELECT userID,firtName,lastName from temp_user where firstName = 'jeff' order by LastName DESC
		 
/* Select userID,firtName,lastName from the temp_user table 
		 	where firstName is jeff and last name is meyers then sorts by lastName 
			in reverse order*/
SELECT userID,firtName,lastName from temp_user where firstName = 'jeff' 
		 and lastName = 'meyers'
		 order by LastName DESC

UPDATE

UPDATE temp_user set firstName = 'jeffrey' where firstName = 'jeff'

DELETE

DELETE from temp_user where fistName = 'jeffrey'