If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > PHP > Select from mysql database

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 08-17-10, 11:33
vladakg vladakg is offline
Registered User
 
Join Date: Aug 2010
Posts: 9
Exclamation Select from mysql database

Can I somehow from the database to found a just determination of the data, namely, I would like if I can somehow found what I want to found a through id. Example: I would like to found a data only where the id is even or odd number, or only the data whose id is less than the number 5, or higher than the number 6 .. Can anyone help me?
Reply With Quote
  #2 (permalink)  
Old 08-17-10, 11:53
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,002
Odd numbers
Code:
WHERE  number_field % 2 = 1
Even numbers
Code:
WHERE  number_field % 2 = 0
Less than 5
Code:
WHERE  number_field < 5
Greater than 6
Code:
WHERE  number_field > 6
__________________
George
Twitter | Blog
Reply With Quote
  #3 (permalink)  
Old 08-17-10, 11:54
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,002
The odds and evens ue the Modulo operator. More info here: MySQL :: MySQL 5.0 Reference Manual :: 11.6.2 Mathematical Functions
__________________
George
Twitter | Blog
Reply With Quote
  #4 (permalink)  
Old 08-17-10, 11:59
vladakg vladakg is offline
Registered User
 
Join Date: Aug 2010
Posts: 9
Thanks man, u rescue me
Reply With Quote
  #5 (permalink)  
Old 08-17-10, 12:17
vladakg vladakg is offline
Registered User
 
Join Date: Aug 2010
Posts: 9
I have one more question. Can someone, call from database only articles where is first letter of name begin from A and end with first name letter T . Just call articels between that thow letters?
Reply With Quote
  #6 (permalink)  
Old 08-17-10, 12:51
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,002
vladakg,

You really need to look in the manual more

Here's one easy method
Code:
WHERE  Left(name, 1) BETWEEN 'A' AND 'T'
__________________
George
Twitter | Blog
Reply With Quote
  #7 (permalink)  
Old 08-17-10, 13:06
vladakg vladakg is offline
Registered User
 
Join Date: Aug 2010
Posts: 9
Thanks again
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On