Beginning SQL

Beginning SQL Beginning SQL

marjan.fesb.hr
from marjan.fesb.hr More from this publisher
20.07.2013 Views

Chapter 3 The results to this query also include The Lion, the Witch, and the Chest of Drawers, a film released in 1977: FilmName On Golden Puddle The Lion, the Witch, and the Chest of Drawers Planet of the Japes The Maltese Poodle Soylent Yellow Before moving on, you should note that while MS Access is happy inserting dates delimited (enclosed by single quotes), when it comes to SELECT statements and WHERE clauses, Access requires any date literals to be enclosed by the hash (#) symbol. For example, consider the following code: WHERE DateOfBirth < #2005-12-23# SQL queries are all about finding answers to questions. The following Try It Out provides a few questions and shows you how SQL can provide answers. Try It Out Querying Your Database 58 Five new members have joined the club, so their details need to be added to the database. The following steps detail how you would add the new members to the Film Club database: 1. Enter the SQL code into your database or download the code from www.wrox.com and then execute it. Included are the new members’ information and INSERT statements to record their favorite category of films. Note that if you’re using Oracle, the date formats must be changed from their current format of year-month-day to the day-month-year format. INSERT INTO MemberDetails (MemberId, FirstName,LastName,DateOfBirth,Street,City,State,ZipCode,Email,DateOfJoining) VALUES ( 10, ‘Susie’,’Simons’,’1937-1-20’,’Main Road’,’Townsville’, ‘Mega State’,’123456’,’susie@mailme.com’,’2005-08-20’ ); INSERT INTO FavCategory (CategoryId, MemberId) VALUES ( 1, 10 ); INSERT INTO FavCategory (CategoryId, MemberId) VALUES ( 3, 10 ); INSERT INTO FavCategory (CategoryId, MemberId) VALUES ( 6, 10 ); INSERT INTO

Chapter 3<br />

The results to this query also include The Lion, the Witch, and the Chest of Drawers, a film released in 1977:<br />

FilmName<br />

On Golden Puddle<br />

The Lion, the Witch, and the Chest of Drawers<br />

Planet of the Japes<br />

The Maltese Poodle<br />

Soylent Yellow<br />

Before moving on, you should note that while MS Access is happy inserting dates delimited (enclosed<br />

by single quotes), when it comes to SELECT statements and WHERE clauses, Access requires any date<br />

literals to be enclosed by the hash (#) symbol. For example, consider the following code:<br />

WHERE DateOfBirth < #2005-12-23#<br />

<strong>SQL</strong> queries are all about finding answers to questions. The following Try It Out provides a few questions<br />

and shows you how <strong>SQL</strong> can provide answers.<br />

Try It Out Querying Your Database<br />

58<br />

Five new members have joined the club, so their details need to be added to the database. The following<br />

steps detail how you would add the new members to the Film Club database:<br />

1. Enter the <strong>SQL</strong> code into your database or download the code from www.wrox.com and then<br />

execute it. Included are the new members’ information and INSERT statements to record their<br />

favorite category of films. Note that if you’re using Oracle, the date formats must be changed<br />

from their current format of year-month-day to the day-month-year format.<br />

INSERT INTO<br />

MemberDetails (MemberId,<br />

FirstName,LastName,DateOfBirth,Street,City,State,ZipCode,Email,DateOfJoining)<br />

VALUES<br />

(<br />

10, ‘Susie’,’Simons’,’1937-1-20’,’Main Road’,’Townsville’,<br />

‘Mega State’,’123456’,’susie@mailme.com’,’2005-08-20’<br />

);<br />

INSERT INTO<br />

FavCategory (CategoryId, MemberId)<br />

VALUES ( 1, 10 );<br />

INSERT INTO<br />

FavCategory (CategoryId, MemberId)<br />

VALUES ( 3, 10 );<br />

INSERT INTO<br />

FavCategory (CategoryId, MemberId)<br />

VALUES ( 6, 10 );<br />

INSERT INTO

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!