Beginning SQL
Beginning SQL Beginning SQL
LocationId 2 2 2 2 1 1 1 Figure 3-6 SELECT * FROM Attendance WHERE MemberAttended = 'Y' MeetingDate 2004-01-01 2004-01-01 2004-01-01 2004-01-01 2004-03-01 2004-03-01 2004-03-01 MemberAttended Y Y Y Y Y Y Y MemberId 1 3 5 6 1 3 4 SELECT * FROM MemberDetails MemberId 1 10 3 4 5 Start by linking the Location and Attendance tables: 13 FirstName Katie Susie Sandra Steve John William LastName Smith Simons Tell Gee Jones Doors SELECT * FROM Location LocationId 1 2 3 Street Main Street Winding Road Tiny Terrace SELECT Attendance.MeetingDate, Location.City FROM Attendance INNER JOIN Location ON Location.LocationId = Attendance.LocationId Extracting Information Email katie@mail.com susie@mailme.com sandra@her_mail.com steve@gee.com jj@jonesmail.org knockon@thedoors.com City Big Apple City Windy Village Big City State New State Golden State Mega State 111
- Page 212: Chapter 3 86 FullName First name is
- Page 216: Chapter 3 Even though DateOfBirth i
- Page 220: Chapter 3 Member Name The member is
- Page 224: Chapter 3 92 The preceding SQL prod
- Page 228: Chapter 3 94 ❑ Category ❑ FavCa
- Page 232: Chapter 3 96 You’re one step furt
- Page 236: Chapter 3 98 FirstName LastName Cat
- Page 240: Chapter 3 This time, you achieve mo
- Page 244: Chapter 3 SQL Is Set-Based 102 You
- Page 248: Chapter 3 104 Category MemberId Thr
- Page 252: Chapter 3 106 You should see the fo
- Page 256: Chapter 3 The overlapping portions
- Page 260: Chapter 3 110 More than one conditi
- Page 266: includes that record. You should al
- Page 270: FirstName LastName DateOfBirth Jenn
- Page 274: 4 Advanced Database Design This cha
- Page 278: Date of Date Meeting Did Member Nam
- Page 282: Now the tables are in second normal
- Page 286: After changing the database so that
- Page 290: IBM’s DB2 doesn’t allow you to
- Page 294: The following code creates a new ta
- Page 298: If you’re using DB2, the code is
- Page 302: The NOT NULL constraint prevents th
- Page 306: In the preceding code, CustomerId i
- Page 310: Foreign Key Foreign keys are column
LocationId<br />
2<br />
2<br />
2<br />
2<br />
1<br />
1<br />
1<br />
Figure 3-6<br />
SELECT * FROM Attendance<br />
WHERE MemberAttended = 'Y'<br />
MeetingDate<br />
2004-01-01<br />
2004-01-01<br />
2004-01-01<br />
2004-01-01<br />
2004-03-01<br />
2004-03-01<br />
2004-03-01<br />
MemberAttended<br />
Y<br />
Y<br />
Y<br />
Y<br />
Y<br />
Y<br />
Y<br />
MemberId<br />
1<br />
3<br />
5<br />
6<br />
1<br />
3<br />
4<br />
SELECT * FROM MemberDetails<br />
MemberId<br />
1<br />
10<br />
3<br />
4<br />
5<br />
Start by linking the Location and Attendance tables:<br />
13<br />
FirstName<br />
Katie<br />
Susie<br />
Sandra<br />
Steve<br />
John<br />
William<br />
LastName<br />
Smith<br />
Simons<br />
Tell<br />
Gee<br />
Jones<br />
Doors<br />
SELECT * FROM Location<br />
LocationId<br />
1<br />
2<br />
3<br />
Street<br />
Main Street<br />
Winding Road<br />
Tiny Terrace<br />
SELECT<br />
Attendance.MeetingDate,<br />
Location.City<br />
FROM Attendance<br />
INNER JOIN Location ON Location.LocationId = Attendance.LocationId<br />
Extracting Information<br />
Email<br />
katie@mail.com<br />
susie@mailme.com<br />
sandra@her_mail.com<br />
steve@gee.com<br />
jj@jonesmail.org<br />
knockon@thedoors.com<br />
City<br />
Big Apple City<br />
Windy Village<br />
Big City<br />
State<br />
New State<br />
Golden State<br />
Mega State<br />
111