Go Back  HTML Forums - Free Webmaster Forums and Help Forums > WEBSITE DEVELOPMENT > Databasing
User Name:
Password:
 

Reply
Thread Tools   Display Modes
  View First Unread
 
Old 09-08-2009, 11:24 AM
  #1
ktsirig
Veteran (Level 7)
 
Join Date: Sep 2005
Posts: 64
iTrader: (0)
ktsirig is an unknown quantity at this point
Perform advanced searches in SELECT statement

Hello all
I wanted to ask if there is a way of inserting some mathematics in an SQL select statement.
What I am interested in is to select all rows from a table where 56<ID<67 for example.

Thank you
ktsirig is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 09-08-2009, 01:10 PM
  #2
cmetz1977
Champion (Level 13)
 
cmetz1977's Avatar
 
Join Date: May 2008
Location: Lakeland, FL
Posts: 217
iTrader: (0)
cmetz1977 will become famous soon enough
SELECT * FROM table WHERE id > '56' AND id < '67'
__________________
Never accept Kool-aid from someone who won't drink from the same punch bowl.
cmetz1977 is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 09-08-2009, 11:19 PM
  #3
JoeyDaly
Lord (Level 16)
 
JoeyDaly's Avatar
 
Join Date: Aug 2007
Location: Melbourne, Australia
Posts: 567
iTrader: (0)
JoeyDaly is on a distinguished road
Also you can use the BETWEEN operator - see here for more: http://www.w3schools.com/Sql/sql_between.asp

I generally use BETWEEN for comparing dates and numbers.
__________________
Joey,
DRUNKhooligan - visit blog
Quote:
Originally Posted by tcw987654321 View Post
...I mean what should I write in the if-else script? (I am a js-idiot)
JoeyDaly is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 09-09-2009, 06:13 AM
  #4
cmetz1977
Champion (Level 13)
 
cmetz1977's Avatar
 
Join Date: May 2008
Location: Lakeland, FL
Posts: 217
iTrader: (0)
cmetz1977 will become famous soon enough
Be sure if you use BETWEEN that it is INCLUSIVE of the values you specify as your range. To get the same result you need to state:

PHP Code:
SELECT FROM table WHERE id BETWEEN '58' AND '66' 
Using BETWEEN '56' AND '67' is the same as ID >= '56' AND ID <= '67'.
__________________
Never accept Kool-aid from someone who won't drink from the same punch bowl.
cmetz1977 is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote

Reply
KEEP TABS
SPONSORS
 
Boxedart



 
 


 
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
  
 
 
 



 
  POSTING RULES
 
 
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Thread Tools
Display Modes

Forum Jump

 

All times are GMT -5. The time now is 12:28 PM.

   

Mascot team created by Drawshop.com

Powered by vBulletin® Version 3.6.7
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.

Server Monitoring by ENIACmonitor 0.01
HTMLforums.com © Big Resources, Inc. Web Design by BoxedArt.com
vRewrite 1.5 beta SEOed URLs completed by Tech Help Forum and Chalo Na.