1. Home
  2. Computing & Technology
  3. PHP / MySQL

MySQL Tutorial: Managing MySQL data

By , About.com Guide

3 of 4

SQL Select Statement - Searching Data

Although in our test database we only have two entries and everything is easy to find, as a database grows it is useful to be able to quickly search the information. From phpMyAdmin you can do this by selecting your database, and then clicking the search tab. Above is an example of how to search for all users under 12 years old.

In our example database this only returned one result, Peggy.

To do this same search from the query window or command line we would type in:

SELECT * FROM people WHERE age < 12

What this does is SELECT *(all columns) from the "people" table WHERE the "age" field is a number less than 12.

If we only wanted to see the names of people who are under 12 years old we could run this instead:

SELECT name FROM people WHERE age < 12

This may be more helpful if your database contains a lot of fields that are irrelevant to what you are currently searching for.

Explore PHP / MySQL
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. PHP / MySQL
  4. Learn MySQL
  5. MySQL Tutorial - SQL Select - SQL Select Statement

©2009 About.com, a part of The New York Times Company.

All rights reserved.