STORED PROCEDURES

Functions: What is the Goddiest line in the bible?

To be sure, the word God occurs a fair few times in the bible. 4117 times at least.:

SELECT count(*) FROM bible WHERE line RLIKE 'god';
+----------+
| count(*) |
+----------+
|     4117 |
+----------+

In fact 4117 is a tad on the low side. The count(*) query scores 1 point for each line with the word 'god' in it, but plenty of lines mention god twice or more. Not to mention all the other ways of naming God: Lord, Jehovah, our Father etc.

Procedures: One Chapter at a Time

Stored Procedures and Functions are a biggy on the MySQL Developer exam. They account for 20% of the marks of the second paper. And no wonder, there's a lot of new functionality (and syntax) to keep in mind. So with that in mind, let's put a procedure together.

Suppose you want to see the all of Genesis Cap 1 together. We can use group_concat() to squidge all the verses in Genesis 1 together on one line.

SELECT GROUP_CONCAT(line  ORDER BY verse SEPARATOR ' ')  as genesis
  FROM bible
 WHERE book = 'Ge'
   AND cap = 1 \G
Syndicate content