Fields

Instead of SELECT *, you can specify which fields to display: SELECT FirstName,LastName FROM Patients (You can add the WHERE and ORDER BY clauses to this.)

Dates: MONTH, DAY, and YEAR

The MONTH, DAY and YEAR functions allow you to select a portion of a date field. These functions can be used in any of the clauses:

SELECT * FROM Patients WHERE MONTH(Birthdate)="3" ORDER BY DAY(Birthdate)
This will select everyone who has a birthday in March and order them by the day of their birthday.

SELECT *,YEAR(NOW())-YEAR(Birthdate) AS age FROM Patients This will add a column called age to the display.


INDEX, Introduction, Queries, The SELECT query, Functions, Select Fields
Next lesson: MySQL (continued)MAIN INDEX
EXAMPLES INDEX

Copyright © Zebra0.com
All rights reserved worldwide.

 
 

Select Fields