Ads by ProfitSence
Close

SQL Table Operations Code Example

Last Updated on Wednesday 5th Oct 2022

Create Table

			
					CREATE TABLE <table name>(
    <column1> <Datatype>,
    <column2> <Datatype>,
    <column3> <Datatype>,
    <column4> <Datatype>,
);

			
	

Delete Table

			
					DROP TABLE table1;

			
	

Add Data

			
					INSERT INTO table1 VALUES (value1,value2,value3,....);

			
	

Updating Records

			
					UPDATE table1 SET column1 = value1 WHERE column2=value2;

Multiple records
UPDATE table1 SET column1 = value1,column2 = value2 WHERE column3=value3;

			
	

Deleting Records

			
					DELETE FROM table1 WHERE <column1=value1;

			
	

Find Data

			
					SELECT column1,column2,.. FROM table1 WHERE column1=value1;

			
	
  • * is a wildcard can be used in place of fields for all fields

can add order

			
					ORDER BY column1,column2 ASC|DESC ;

			
	

Multiple Tables

			
					Select * from table1,table2 where column1=value2 AND column1=table2.column2;