How to use MySQL 5 Part 3: Selecting Data |
||||||||||||
This article and tutorial describes and demonstrates how you can:
-
[ click here ] Reading an Entire Table With Select *
-
[ click here ] Reading only certain Columns With Select Column_Name
-
[ click here ] Reading only certain Data With Select Where
-
[ click here ] Reading Totals and Similar With Select Sum, Avg, Min, Max, Count
The MySQL SELECT command is how you get information from the tables you create and use. It is the primary way of reading information from your mysql database.
SELECT SYNTAX
Steps To Read all of theData in a table using the |
Visual Demonstration |
|---|---|
|
Syntax:
Select * From MyTable
"SELECT is used to retrieve rows selected from one or more tables, and can include UNION statements and subqueries. ... "
[ return to top ]
The MySQL SELECT command can be used to Read specfic information. You don't have to look at every piece of information available, instead you can just look at fields or columns you want to see.
SELECT SYNTAX
Steps To Read Specific Column Data using the |
Visual Demonstration |
|---|---|
|
Syntax:
Select Customer_Number,Customer_Name From MyCustomers;
[ return to top ]
The MySQL SELECT command can be used to Read specfic rows. You don't have to look at every line of information available, instead you can just look at rows you want to see.
SELECT SYNTAX
Steps To Read Specific Row Data using the |
Visual Demonstration |
|---|---|
|
Syntax:
Select Customer_Number,Customer_Name From MyCustomers Where Customer_Number>100;
You can use compartive operators like:
-
> (greater than)
-
< (less than)
-
= (equals)
-
!= (not equal)
-
>= (greater than or equal)
-
<= (less than or equal)
[ return to top ]
The MySQL SELECT command can be used to Read specfic information. You can do things like get totals, count how many items are available, get the smallest item, get the largest column and even average a field.
SELECT SYNTAX
Steps To Read and Perform Specific Functions on Column Data using the |
Visual Demonstration |
|---|---|
|
Syntax:
Select Min(Price) From PriceList Where Item='Books';
or
Select Count(*) From MyCustomers;
or
Select Sum(Amount) From Sales Where ItemSold='Pizza'';
Aggregate (also known as Summary) functions include:
-
min (minimum)
-
max (maximum)
-
avg (avergage)
-
count (count)
-
sum (total)
[ return to top ]















