|
|
|
|
![]() ![]() |
Mar 29 2006, 02:05 PM
Post
#1
|
|
|
Privileged Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 535 Joined: 14-February 05 From: Oslo, Norway Member No.: 3,759 |
I have a int column with numbers, and I want to show only the numbers between 5 and 20 in that column.
So my list would be like this: CODE 5 7 15 16 I know how to only show numbers that are less than 20 or greater than 5, but I can't manage to combine those two (Less than 20 AND greater than 5). So I guess it would be something like this: CODE SELECT * FROM `table` WHERE `introw` >= 5 && <= 20 How can I do that? |
|
|
|
Mar 29 2006, 03:50 PM
Post
#2
|
|
|
Trap Grand Marshal Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 1,205 Joined: 25-March 05 Member No.: 4,883 |
Try this.
CODE SELECT * FROM Table WHERE Column>= 5 AND Column<= 20 This is another alternative CODE SELECT * FROM Table WHERE Column BETWEEN 5 AND 20 Please take note that there is no ' signs to enclose the table name and column name. |
|
|
|
Mar 29 2006, 05:11 PM
Post
#3
|
|
|
Privileged Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 535 Joined: 14-February 05 From: Oslo, Norway Member No.: 3,759 |
Thanks alot!
|
|
|
|
Mar 30 2006, 01:22 PM
Post
#4
|
|
|
Privileged Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 874 Joined: 30-July 04 Member No.: 246 |
Just as a side note, table and field names can be enclosed in ` symbols (note that it is a grave accent mark, and not a standard quotation mark as you would use to delimit a string value), but it is not required. It is often useful to make it easier to spot the tables/fields referenced, and as it doesn't have any influence on performance whatsoever, it doesn't really make any difference whether you use it or not.
|
|
|
|
Mar 30 2006, 03:42 PM
Post
#5
|
|
|
Privileged Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 535 Joined: 14-February 05 From: Oslo, Norway Member No.: 3,759 |
I know, and I use to use the ` symbols. Thanks for telling me anyway
|
|
|
|
Mar 30 2006, 04:01 PM
Post
#6
|
|
|
Trap Grand Marshal Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 1,205 Joined: 25-March 05 Member No.: 4,883 |
Oh Spectre thanks. I didn't know that SQL statements accept ' signs. For me to differentiate between the table or column names and the SQL codes, I usually use block letters for SQL codes and follows the same cases for the table and column names as in the database. Now I'm learnt something new too, that I never realised.
|
|
|
|
![]() ![]() |
Similar Topics
|
Lo-Fi Version | Time is now: 16th May 2008 - 02:50 PM |