SQL Syntax
  << h o m e

------------------Creating a table

 

CREATE TABLE <table_name> (<field_name_1> <field_type_1> <modifiers>,

<field_name_2> <field_type_2> <modifiers>, ... , <field_name_n>

<field_type_n> <modifiers>,

PRIMARY KEY (field_id))

 

------------------Altering a column type

 

ALTER TABLE <table_name> MODIFY <old_field_name> <new_field_type>

<modifiers>

 

------------------Adding a new field

 

ALTER TABLE <table_name> ADD <new_field_name> <new_field_type>

 

------------------Adding an index

 

ALTER TABLE <table_name> ADD INDEX <index_name> (column_name);

 

------------------Removing a column

 

ALTER TABLE <table_name> DROP  <column_name>;

 

------------------Insert data into a table

 

INSERT into <table_name (field_name_1, field_name2, field_name_n) VALUES

(value_1, value_2, value_n)

 

------------------Changing a column name

 

ALTER TABLE <table_name> CHANGE <old_column_name> <new_column_name> <new_column_definition>

 

------------------Delete contents of a table

DELETE FROM <table_name>

 

------------------Basic structure for defining a record number column

 

defining a recno:

recno int not null auto_increment

 

------------------Left join select structure

SELECT * FROM <table1> left join <table_to_join2> on <table_to_join2.column> = <table1.column>;

 

------------------Insert ... Select statement

INSERT INTO <table 1> (columns_to_be_inserted_into) SELECT <table2.column> FROM <table2> WHERE condition;

 

------------------Insert Multiple values into one table

INSERT INTO table (column1, column2, column3) VALUES ($one, $two, $three),($four, $five, $six),($seven, $eight, $nine)

  who is f l u i d consulting?
 

http://www.fluidconsulting.com

  << h o m e