In this post I have explained some simple queries with an explanation. This may help ful for beginners.

SELECT QUERY:

select fieldname(s) from tablename

eg: select itemid,itemname,itemdesc from tbl_Item

UPDATE QUERY:

update tablename set col1=@param1,col2=@param2

eg: update tbl_Item set itemname = @itemname,itemdesc = @desc where itemid = @itemid

Here you can use the where condition to update a particular column in the table. If you need to update the values without any condition then you can have the same query but with out the where condition. Please see below for your reference,

eg: update tbl_Item set itemname = @itemname,itemdesc = @desc

Note: @itemname,@desc are the parameter.

DELETE QUERY:

delete from tablename

eg: delete from tbl_Item where itemid = @itemid

here you can delete the particular rows of a table. Thats is you can delete rows or data for particular itemid. But you can delete whole table with out anycondition you can use the same with out where condition.

TRUNCATE TABLE:

truncate table tablename

eg: truncate table tbl_Item

DIFF BETWEEN DELETE AND TRUNCATE:


Delete command removes the rows from a table based on the condition that we provide with a WHERE clause. Truncate will actually remove all the rows from a table and there will be no data in the table after we run the truncate command. Simply said it will reset the table with the new one. But it wont affect the structure of the table.

INSERT QUERY:

insert into tablename(col1,col2,col3) values(@param1,@param2,@param3)

eg:  insert into tbl_Item(itemname,desc) values(@itemname,@desc)