O'Reilly logo

Learning PHP and MySQL by Jon A. Phillips, Michele E. Davis

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Structured Query Language

Now that you've defined a table, you can add data to it. MySQL will keep track of all the details. To manipulate data, use the Structured Query Language (SQL) commands. Because it's been designed to easily describe the relationship between tables and rows, the database uses SQL to modify data in tables.

SQL is a standard language used with any database such as MySQL, Oracle, or Microsoft SQL Server. It was developed specifically as a language used to retrieve, add, and manipulate data that resides in databases. We'll get into the nitty gritty of MySQL in Chapter 8, but we'll start with some easy-to-use commands. We're going to start with creating tables.

Tip

Each database adds on its own extensions to the standard SQL. These are usually more advanced capabilities, such as an outer join. An outer join is a special way of linking two tables so that data from one of the tables is included even if there isn't a match in the other table. The syntax for outer joins for tables in Oracle is a plus within parentheses (+), whereas MySQL uses the syntax left join on to perform an outer table join.

Creating Tables

Use the create table command to specify the structure of new database tables. When you create a database table, each column has a few options, in addition to the column names and data types. Values that must be supplied when adding data to a table use the NOT NULL keyword. The PRIMARY KEY keyword tells MySQL which column to use as a key field. Then, you have ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required