Beginning SQL
Beginning SQL Beginning SQL
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
- Page 106: Generally speaking, picking a data
- Page 110: example, the MemberId field links t
- Page 114: Depending on which RDBMS you’re u
- Page 118: The FilmCategory table is very smal
- Page 122: 2 Entering Information The last cha
- Page 126: like this: INSERT INTO Category VAL
- Page 130: Inserting Data into the Case Study
- Page 134: The WHERE Clause So far you’ve se
- Page 138: Try It Out Using Logical Operators
- Page 142: Exercises 1. Three new members have
- Page 148: Chapter 3 54 MemberId FirstName 1 K
- Page 152: Chapter 3 The results are as follow
- Page 158: MemberDetails (MemberId, FirstName,
- Page 162: MemberDetails table, the columns Fi
- Page 166: State DateOfJoining New State 2005-
- Page 170: It simply tells the database system
- Page 174: The BETWEEN operator functions exac
- Page 178: The final condition required is a c
- Page 182: In some database systems, the LIKE
- Page 186: The second query is a negative, in
- Page 190: Because both conditions (YearReleas
- Page 194: YearReleased 1984 1980 1977 1975 19
- Page 198: First, the database system orders t
- Page 202: LastName FirstName DateOfBirth Nigh
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