Query help

Results 1 to 2 of 2

Thread: Query help

  1. #1
    Join Date
    Dec 1969

    Default Query help

    I&#039;m doing an online bible for a church. I&#039;m trying to set it up so you can search by chapter and verse.<BR>How would i write the query, for example, that would show all the records from Matthew Chapter 20 verse 20 to Mark Chapter 1 verse 5.<BR>The fields are Book, Chapter, Verse, ID.<BR>Thanks<BR>

  2. #2
    Shyam P.S. Shekhawat Guest

    Default RE: Query help

    Condition for your query<BR>-Your Id coloum should be unique and descending.<BR>-you would execute three queries.<BR><BR>query 1<BR>-To find out the Id of Matthew chapter 20 verse 20.<BR> "select ID from tblname where Book=&#039;Matthew&#039; and Chapter=&#039;20&#039; and Verse=&#039;20&#039;" <BR>-Take this Id in a variable(say firstId)<BR><BR>query 2<BR>-To find out the Id of Mark chapter 1 verse 5.<BR> "select ID from tblname where Book=&#039;Mark&#039; and Chapter=&#039;1&#039; and Verse=&#039;5&#039;" <BR>-Take this Id in a variable(say secondId)<BR><BR>Query 3<BR>Now get the result<BR> "select top &#039;" &secondId& "&#039; * from tblname where ID not in (select top &#039;" &firstId& "&#039; from tblname)"<BR><BR>here<BR>tblname=your table name<BR><BR>You can do this by stored procedure also.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts