If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > how to search sql with from and to

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-10-11, 16:05
gilgalbiblewhee gilgalbiblewhee is offline
Registered User
 
Join Date: Jul 2004
Posts: 494
how to search sql with from and to

Is there a proper syntax or method of doing the following?
Quote:
$query = "SELECT * FROM ".$dbTable7." WHERE [from] book = '" .$book. "' AND [from] chapter= '" . $chapter. "' [to] book = '" .$book. "' AND [to] chapter= '" . $chapter. "' ORDER BY id ASC";
Reply With Quote
  #2 (permalink)  
Old 02-10-11, 16:22
r937 r937 is online now
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,535
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

__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 02-10-11, 16:57
gilgalbiblewhee gilgalbiblewhee is offline
Registered User
 
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.
Reply With Quote
  #4 (permalink)  
Old 02-10-11, 17:34
r937 r937 is online now
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,535
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 )
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On