20.07.2013 Views

Beginning SQL

Beginning SQL

Beginning SQL

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 5<br />

You also learned that math and string functions can throw up unexpected results when dealing with<br />

NULL values. In particular, NULL propagates so that if a query finds just one occurrence of NULL in an<br />

expression, the whole expression evaluates to NULL. The COALESCE function can help deal with that by<br />

returning a different value if NULL is found.<br />

Finally, this chapter covered copying a whole table, or selected columns in a table, to another table by<br />

using INSERT INTO in conjunction with SELECT statements.<br />

That’s it for this chapter. The next chapter looks at more complex joins.<br />

Exercises<br />

1. The film club chairperson wants a list of members’ names and addresses. She needs only the<br />

street and zip code. If either the Street column or the ZipCode column is NULL, make sure that<br />

the address is listed as No address details available for this member.<br />

2. This question is for MS <strong>SQL</strong> Server and IBM DB2 users. After speaking to a member at a club<br />

meeting last night, the film club chairperson wants to contact the member again but can’t quite<br />

remember her name. She thinks it sounds something like Jilly Johns. Can you help track down<br />

the person using a <strong>SQL</strong> query?<br />

188

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

Saved successfully!

Ooh no, something went wrong!