Creating a database
After you've signed on with a MySQL-enabled web host, consult their technical support staff and documentation to get the instructions for creating your first database on their servers. Be sure the login and password information needed to connect to your database is among these instructions.
Once you've created the database, your next step is to make a table of sample data for it. Begin that process by logging onto the MySQL web interface that your host has made available.
Click the name of your database to display the form with the following links near the top: "Structure," "SQL," "Search," "Query" and others. Near the bottom of that page, seek the text "Create new table on database <your database name>". In the text box next to that text, type "MoviesTable," and enter "3" in the text box next to the "Number of fields" text.
The MySQL form for adding new tables
Describe the fields of the Movies table in the next form that appears: type these values for the "Field" column:
Specify the length of the field in the "Length/Values" column: enter these values, which correspond to the field names you just entered:
In the "Type" field, change just one of the values in the dropdown boxes: make the "Type" value for "YearReleased" read "INT."
Press the "Save" button to make MySQL create the actual table.
Insert a row with the web interface
Insert a row representing the information for one movie, into your new table. Press the "Insert" link, then type in "Close Encounters of the Third Kind," or some other movie title, in the "Value" field of the "MovieTitle" row. Complete the "Director" and "YearReleased" fields in the same way. (You can type "Spielberg" and 1977" for the "Close Encounters" movie.)
Press the "Go" button near the bottom of the form to create the new record. On the page that follows, look for confirmation of the entry in the form of text that reads something like this: "Inserted rows: 1"
Notice the text in the section "SQL query:" That text is the SQL equivalent of the insertion action you just took. If you'd entered that statement at the MySQL command prompt, the row would have been inserted just as effectively.
Write some SQL
Dig deeper in the SQL language itself by creating some queries with it, as opposed to using the form to create queries. Click the "SQL" link, then notice the default statement that appears in the SQL window:
SELECT * FROM `MoviesTable` WHERE 1
If you don't see that statement in the window, paste it in now, then press the "Go" button at the right of the window. MySQL executes your query, and displays the results in the form of a table.
The MySQL SQL window
Only one row was returned, since we've only entered one row in the table thus far. Insert more rows of movie information--but using SQL this time. Click the "SQL" link again to return to the SQL window. Enter the following statement in the window to create two new rows of movie information. Remember to press the "Go" button after pasting the statement in the SQL window.
Insert into MoviesTable (MovieTitle, Director, YearReleased) values ('Das Boot', 'Petersen', '1982'), ('Raiders of the Lost Ark', 'Spielberg', '1981');
The other common SQL functions besides INSERT and SELECT are UPDATE and DELETE. We'll cover those statements in the final section of this article.