Welcome Guest ( Log In | Register)



 
Reply to this topicStart new topic
> Showing Numbers With Mysql
Amezis
post 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?
Go to the top of the page
 
+Quote Post
Inspiron
post 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.
Go to the top of the page
 
+Quote Post
Amezis
post 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! smile.gif
Go to the top of the page
 
+Quote Post
Spectre
post 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.
Go to the top of the page
 
+Quote Post
Amezis
post 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 smile.gif
Go to the top of the page
 
+Quote Post
Inspiron
post 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.
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Problem On Mysql "order By"(5)
  2. Increment A Mysql Column(6)
  3. Can You Add Images Into A Mysql Database?(20)
  4. Creating Profiles In Php/mysql ?(7)
  5. Php Search Engine Script For Mysql Database(11)
  6. Script Not Working :s(5)
  7. How To Delete A Row In Mysql.(4)
  8. Importing .csv Into Mysql Database(6)
  9. Editing Information In A Mysql Database And Deleting Rows(5)
  10. Putting Data Of 2 Pages In Mysql At Once(1)
  11. Mysql Query(2)
  12. Simple Mysql Query Limiting(9)
  13. Phpbb2 Error(4)
  14. Some Mysql Basics(4)
  15. Php, Mysql, Apache(4)
  1. Php And Mysql Applications(3)
  2. Getting Php 5 To Work With Mysql(0)
  3. Problem With A Mysql Join(2)
  4. The Artists Tutorials :mysql Basic Commands(0)
  5. [mysql]get Id Of Loged In User?(7)
  6. [mysql/php]need Som Basic Help(13)
  7. [php/mysql]id Trouble [resolved](3)
  8. Mysql Won't Update(2)
  9. Php + Mysql Question!(4)
  10. Tools Needed!(6)
  11. Best Sites For Learning Php-mysql(4)
  12. Php And Mysql Programming(2)
  13. Best Php And Mysql Editor For Noobs(5)


 



- Lo-Fi Version Time is now: 16th May 2008 - 02:50 PM