User Tools

Site Tools


sample_queries

This is an old revision of the document!


Sample Queries

Here's some sample queries to get someone started if they are looking to do some more advanced lookups. Each of these uses the SQLite export, and does JOINs across all the tables instead of using the normalized scriptures table.

In each query, it's important to remember to order the output by the verse IDs, since the natural ordering may shift around if you've made changes to your database. That possibility is rare, but it's going to keep your queries safe.

Synoptic Gospels

Query all the verses from the Synoptic Gospels (Matthew, Mark, and Luke):

SELECT b.book_title || ' ' || c.chapter_number || ':' || v.verse_number AS verse_title, v.scripture_text FROM verses v JOIN chapters c ON v.chapter_id = c.id JOIN books b ON c.book_id = b.id JOIN volumes vo ON b.volume_id = vo.id WHERE b.book_title IN ('Matthew', 'Mark', 'Luke') ORDER BY v.id;

Partial result set:

Matthew 1:1|The book of the generation of Jesus Christ, the son of David, the son of Abraham.
Matthew 1:2|Abraham begat Isaac; and Isaac begat Jacob; and Jacob begat Judas and his brethren;
Matthew 1:3|And Judas begat Phares and Zara of Thamar; and Phares begat Esrom; and Esrom begat Aram;
Matthew 1:4|And Aram begat Aminadab; and Aminadab begat Naasson; and Naasson begat Salmon;
Matthew 1:5|And Salmon begat Booz of Rachab; and Booz begat Obed of Ruth; and Obed begat Jesse;
Matthew 1:6|And Jesse begat David the king; and David the king begat Solomon of her that had been the wife of Urias;
Matthew 1:7|And Solomon begat Roboam; and Roboam begat Abia; and Abia begat Asa;
Matthew 1:8|And Asa begat Josaphat; and Josaphat begat Joram; and Joram begat Ozias;
Matthew 1:9|And Ozias begat Joatham; and Joatham begat Achaz; and Achaz begat Ezekias;
Matthew 1:10|And Ezekias begat Manasses; and Manasses begat Amon; and Amon begat Josias;
Matthew 1:11|And Josias begat Jechonias and his brethren, about the time they were carried away to Babylon:
Matthew 1:12|And after they were brought to Babylon, Jechonias begat Salathiel; and Salathiel begat Zorobabel;
Matthew 1:13|And Zorobabel begat Abiud; and Abiud begat Eliakim; and Eliakim begat Azor;
Matthew 1:14|And Azor begat Sadoc; and Sadoc begat Achim; and Achim begat Eliud;
Matthew 1:15|And Eliud begat Eleazar; and Eleazar begat Matthan; and Matthan begat Jacob;
sample_queries.1553461357.txt.gz · Last modified: 2019/03/24 15:02 by steve