Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2004
    Posts
    494

    Unanswered: how to search sql with from and to

    Is there a proper syntax or method of doing the following?
    $query = "SELECT * FROM ".$dbTable7." WHERE [from] book = '" .$book. "' AND [from] chapter= '" . $chapter. "' [to] book = '" .$book. "' AND [to] chapter= '" . $chapter. "' ORDER BY id ASC";

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Quote Originally Posted by gilgalbiblewhee View Post
    Is there a proper syntax or method of doing the following?
    you forgot to mention what "doing the following" is supposed to accomplish

    for starters, remove the [from] and [to] business

    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Jul 2004
    Posts
    494
    Quote Originally Posted by r937 View Post
    you forgot to mention what "doing the following" is supposed to accomplish

    for starters, remove the [from] and [to] business

    :)
    Yes. I know it doesn't belong there. But what I want to know is how to select from a certain book and chapter to another book and chapter...whatever is in between.

  4. #4
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Quote Originally Posted by gilgalbiblewhee View Post
    ... how to select from a certain book and chapter to another book and chapter...whatever is in between.
    Code:
    WHERE ( book > $bookfrom
         OR book = $bookfrom
        AND chapter >= $chapterfrom )
      AND ( book < $bookto
         OR book = $bookto
        AND chapter <= $chapterto )
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

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