Jump to content
xisto Community
Sign in to follow this  
Amezis

Showing Numbers With Mysql

Recommended Posts

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:

571516

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:
SELECT * FROM `table` WHERE `introw` >= 5 && <= 20
How can I do that?

Share this post


Link to post
Share on other sites

Try this.

SELECT * FROM Table WHERE Column>= 5 AND Column<= 20

This is another alternative

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.