Community Based Support.

Using WHERE to limit data in MySql and PHP

Using WHERE to limit data in MySql and PHP

You can add a WHERE part to your SQL. But before you do, make sure you read the security section.

Using WHERE limits the records returned from a SQL statement. Most of the time, you don’t want to return all the records from your table. Especially if you have a large number of records. This will just slow things down unnecessarily. Instead, use WHERE. In the SQL below, we’re using WHERE to bring back only the matching records from the AddressBook table:

$SQL = "SELECT * FROM AddressBook WHERE email = 'me@me.com' ";

When the following code is run, only the records that have an email field of me@me.com will be returned.