Results 1 to 7 of 7
  1. #1
    Join Date
    Aug 2010
    Posts
    9

    Exclamation Unanswered: 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?

  2. #2
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    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
    Home | Blog

  3. #3
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    The odds and evens ue the Modulo operator. More info here: MySQL :: MySQL 5.0 Reference Manual :: 11.6.2 Mathematical Functions
    George
    Home | Blog

  4. #4
    Join Date
    Aug 2010
    Posts
    9
    Thanks man, u rescue me

  5. #5
    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?

  6. #6
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    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
    Home | Blog

  7. #7
    Join Date
    Aug 2010
    Posts
    9
    Thanks again

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •