Chapter 2. Managing Data with SQL

In This Chapter

  • Working with SQL script files

  • Using AUTO_INCREMENT to build primary key values

  • Selecting a subset of fields

  • Displaying a subset of records

  • Modifying your data

  • Deleting records

  • Exporting your data

Although we tend to think of the Internet as a series of interconnected documents, the Web is increasingly about data. The HTML and XHTML languages are still used to manage Web documents, but the SQL (Structured Query Language) — the language of data — is becoming increasingly central. In this chapter, you discover how SQL is used to define a data structure, add data to a database, and modify that data.

Writing SQL Code by Hand

Although you can use phpMyAdmin to build databases, all it really does is write and execute SQL code for you. You should know how to write SQL code yourself for many reasons:

  • It's pretty easy. SQL isn't terribly difficult (at least, to begin with — things do get involved later).Writing the code in SQL is probably easier for you to write than to creating the code in phpMyAdmin.

  • You need to write code in your programs. You probably run your database from within PHP programs. You need to be able to write SQL commands from within your PHP code, and phpMyAdmin doesn't help much with that job.

  • You can't trust computers. You should understand any code that has your name on it, even if you use a tool like phpMyAdmin to write the code. If your program breaks, you have to fix it eventually, so you really should know how it works.

  • SQL scripts ...

Get HTML, XHTML, & CSS All-in-One For Dummies®, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.