SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    Patience... bronze trophy solidcodes's Avatar
    Join Date
    Jul 2006
    Location
    Philippines
    Posts
    911
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)

    Arrow selecting the odd number id only of the records? very easy.

    ok let say i have 10 records

    and it has auto increment id.

    now i want to select only the odd numbers of the id?

    example: id: 1, 3, 5, 7, 9

    how can i do this using SELECT?

    thank you in advance.

  2. #2
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,580
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Code:
    SELECT id FROM table WHERE MOD(id,2) = 1
    MOD is the modulus operator which returns the remainder of integer division. Any odd number divided by 2 will have a remainder of 1.


Bookmarks

Posting Permissions

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