My database looks like this:
Book,Chapter,Verse,Scripture
"1","1","1","1text1"
"1","1","2","1text2"
"1","1","3","1text3"
"1","1","4","1text4"
"1","2","1","2text1"
"1","2","2","2text2"
"1","2","3","2text3"
I want to select all the rows from 1,1,1 to 1,2,3.
However my current query will not return row 1,1,4 because 4 is greater than 3.
SELECT * FROM my_table WHERE
Book >= 1 AND Book <= 1 AND
Chapter >= 1 AND Chapter <= 2 AND
Verse >= 1 AND Verse <= 3
MySQL also supports row constructors. If you wanted (e.g.) 1 1:3 through 1 2:2, use:
For 58 1:3 to 62 4:2,
58 1:4 will be included, as will 59 1:1 and 60 10:10, but not 62 5:1.
I can’t find much documentation, but MySQL follows the behavior set down for row comparisons since SQL-92 (note: the link is to a draft version), specifically Section 8.2 “General Rules” 7):
Row comparisons are covered in section 9.2 Joe Celko’s SQL For Smarties (link is to 3rd Ed., but the same topic existed in earlier editions).