SQL: The first example

Let’s look at our first MySQL example.  This example is a slight modification of the example given by sqlfiddle.com.

CREATE TABLE supportContacts 
 id int auto_increment primary key, 
 type varchar(20), 
 details varchar(30)

INSERT INTO supportContacts
(type, details)
('Name', 'Daryl'),
('Phone', '91118888'),
('Country', 'Singapore'),
('Occupation', 'Engineer');

The above code is for building the structure and data for the database.  There are 3 columns – id, type and details in the table supportContacts.

To put the data into the table supportContacts, we use the insert into statement.  Each row of data in the table is called a record.


On the right of the screenshot, we have our first query statement:

select id, type, details from supportContacts

It means we are selecting all the 3 columns for display.  The displayed table is shown on the bottom of the page.

Series Navigation<< SQL: Database and tables
SQl: Create table with variables >>