View Single Post
Old 08-07-2011, 10:28 AM  
cooldude7
Confirmed User
 
cooldude7's Avatar
 
Industry Role:
Join Date: Nov 2009
Location: Heaven
Posts: 4,306
Quote:
Originally Posted by critical View Post
If you are trying to obtain a range, just use mysql's range function:

May times the programmer needs to find out some specific data which lies in the particular range of values but there is not any predefined function in MySQL but we can also find that particular range's data from the database in MySQL using BETWEEN and AND clauses or write your own simple query.

Syntax:

exp BETWEEN min_value AND max_value
The above syntax is equivalent to the expression (min_value <= exp AND exp <= max_value).

In the following example we will describe you that how one can find out specific data lying between some range. To fire query we must have some data into a table therefore we will first create a table and fill some data into it.

Example:

SELECT id, name, subject from mca where
mca.id BETWEEN 2 AND 5;
Above query can also be written as below:

SELECT id, name, subject from mca where
( mca.id >=2 && mca.id <=5);
thanks for your time.,

because of ur explaination i have found something very useful for me.,


Code:
mysql> SELECT 1 BETWEEN 2 AND 3;

now my query looks like this., with start point and exnd point.,

$result = mysql_query("SELECT content.*, content_views.views AS views FROM content, content_views WHERE content_views.content = content.record_num AND content.approved = 2 AND content.enabled = 1 AND record_num BETWEEN 1000 AND 1200 ORDER BY encoded_date");



thanks a lot.
cooldude7 is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote