Section A.7. Chapter 7


A.7. Chapter 7


Solution to Question 7-1

Create the months table as follows:

 CREATE TABLE months (    month_id INT NOT NULL AUTO_INCREMENT,    month VARCHAR (20),    days INT,    PRIMARY KEY (month_id)); 


Solution to Question 7-2

To add the months to the new table, specify:

 INSERT INTO months VALUES (NULL,'January',31); INSERT INTO months VALUES (NULL,'February',28); INSERT INTO months VALUES (NULL,'March',31); INSERT INTO months VALUES (NULL,'April',30); INSERT INTO months VALUES (NULL,'May',31); INSERT INTO months VALUES (NULL,'June',30); INSERT INTO months VALUES (NULL,'July',31); INSERT INTO months VALUES (NULL,'August',31); INSERT INTO months VALUES (NULL,'September',30); INSERT INTO months VALUES (NULL,'October',31); INSERT INTO months VALUES (NULL,'November',30); INSERT INTO months VALUES (NULL,'December',31); 


Solution to Question 7-3

To display the months, use the query SELECT * FROM months;.


Solution to Question 7-4

To display only the months that have 28 days, use the query SELECT * FROM months WHERE days = 28;.


Solution to Question 7-5

To display only the months that end in "ber," use SELECT * FROM months WHERE months LIKE '%ber';.



Learning PHP and MySQL
Learning PHP and MySQL
ISBN: 0596101104
EAN: 2147483647
Year: N/A
Pages: 135

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net