O'Reilly logo

PHP and MySQL for Dynamic Web Sites: Visual Quickpro Guide, Second Edition by Larry Ullman

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

Using Conditionals

The problem with the SELECT statement as I have used it thus far is that it will automatically retrieve every record. While this isn’t a big issue when dealing with a few rows of information, it will greatly hinder the performance of your database as the number of records grows. To improve the efficiency of your SELECT statements, you can use different conditionals in an almost limitless number of combinations. These conditionals use the SQL term WHERE and are written much as you’d write a conditional in PHP.

SELECT * FROM tablename WHERE columnname
→ = 'value'

SELECT email FROM users WHERE last_name
→ = 'Lennon'

SELECT name FROM people WHERE birth_date
→ = '2005-01-26'

Table 4.7 lists the most common operators you would ...

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