telophase: (Gin waves byebye)
telophase ([personal profile] telophase) wrote2009-01-16 08:30 am
Entry tags:

memeage

Grab the book nearest you. Right now. Turn to page 56. Find the fifth sentence. Post that sentence along with these instructions in your LiveJournal. Don't dig for your favorite book, the coolest, the most intellectual. Use the CLOSEST.

For example, to count the number of waterfalls associated with a county, specify
SELECT COUNT(u.county_id) AS county_count
FROM upfall u;

6


From SQL Pocket Guide 2nd edition by Jonathan Gennick

Aren't you excited?

[identity profile] tool-of-satan.livejournal.com 2009-01-16 03:13 pm (UTC)(link)
I hope that makes more sense in context - as quoted that statement does not do what the description says it does.

[identity profile] telophase.livejournal.com 2009-01-16 03:16 pm (UTC)(link)
?

I'm just confused at the way all their tables are named things like "upfall u" but they use "u.county_id" to access the field in it. Not that I've bothered to read the front matter to find out what their example database looks like; this is just one of a number of vaguely recent SQL books I pulled from the stack to pile on my desk for my current project. :)

[identity profile] tool-of-satan.livejournal.com 2009-01-16 04:45 pm (UTC)(link)
In the example, the table is named upfall - the "u" is an alias which is only valid in that statement. In this statement, since there is only one table the alias is not really necessary, but in something like this they are useful:
SELECT d.name dept_name, e.name emp_name
  FROM employees e, depts d
 WHERE d.id = e.dept_id;


The aliases say "in this SQL statement when I use 'e' I mean the employees table and when I use 'd' I mean the depts table."

You could write this statement without aliases, but if your tables have long names it gets messy (and if you use the same table twice in a statement you must use aliases):
SELECT depts.name dept_name, employees.name emp_name
  FROM employees, depts
 WHERE depts.id = employees.dept_id;


As for the statement from the book, all it does is count the number of waterfalls which have a non-NULL county_id, which is probably all of them.

[identity profile] telophase.livejournal.com 2009-01-16 04:47 pm (UTC)(link)
Thanks! I think the aliases thing will be terribly helpful would have been earlier this week in what I do here. :D

[identity profile] tool-of-satan.livejournal.com 2009-01-16 05:05 pm (UTC)(link)
Well, you should have called me sooner. :)

[identity profile] telophase.livejournal.com 2009-01-16 05:06 pm (UTC)(link)
I shall annoy the hell out of you! XD

(But today I have to do data entry of new subject categories for 400+ databases *cries*)

[identity profile] readsalot.livejournal.com 2009-01-16 07:52 pm (UTC)(link)
Oh god I'm sorry. I take it the field got redefined as char from text and this is the fix? I thought your manager would have had someone who could write a Perl script. (*is really, really sorry*)

[identity profile] telophase.livejournal.com 2009-01-16 07:54 pm (UTC)(link)
Uh, no. It was varchar from the start. The fix was to stop messing about in Access and to write an ASP script for entering the data. :)
ext_7025: (cure for anything)

[identity profile] buymeaclue.livejournal.com 2009-01-16 03:47 pm (UTC)(link)
I like knowing about waterfalls!
kate_nepveu: sleeping cat carved in brown wood (Default)

[personal profile] kate_nepveu 2009-01-16 04:32 pm (UTC)(link)
If, however, personal jurisdiction is established under this paragraph with respect to a federal claim, then 28 U.S.C. sec. 1367(a) provides supplemental jurisdiction over related claims against that defendant, sujbect to the court's discretion to decline exercise of that jurisdiction under 28 U.S.C. sec. 1637(c).
--_Federal Civil Judicial Procedure and Rules_, 2008 revised edition

[identity profile] readsalot.livejournal.com 2009-01-16 07:58 pm (UTC)(link)
There's a rule about when you can omit the ampersand and when you cannot; we'll see that rule by the end of the chapter. (Chapter 4, Subroutines, of Learning Perl, 3rd edition, by Randal L. Schwartz & Tom Phoenix)

(I'm not still learning Perl, but it's a nice quick reference book.)

[identity profile] tprjones.livejournal.com 2009-01-17 02:17 am (UTC)(link)
"4. Scroll to the song and press the trackball to play." - excerpted from Getting Started: The Blackberry Pearl 8220 Flip

[identity profile] seawolf10.livejournal.com 2009-01-18 05:51 am (UTC)(link)
I'm doing American Lit 1860-1912 coursework.

"But if the white parent is the father, instead of the mother, the offspring are unblushingly reared for the market."

From Harriet Jacobs' Incidents in the Life of a Slave Girl.