Activity Stream
48,167 MEMBERS
64689 ONLINE
besthostingforums On YouTube Subscribe to our Newsletter besthostingforums On Twitter besthostingforums On Facebook besthostingforums On facebook groups

Page 1 of 2 12 LastLast
Results 1 to 10 of 17
  1.     
    #1
    Member
    Website's:
    FunLinkz.com Smyu.in

    Post SQL Help

    This is a easy code but I am not able to figure it as Im fairly new to SQL.

    Example I have a table like this-
    Name: ID:
    abcde 1
    efghia 3
    pofjsa 5
    asklda 6

    I want to sort the tables according to increasing ID.
    Like this-
    Name: ID:
    abcde 1
    efghia 2
    pofjsa 3
    asklda 4


    Assuming that the ID's are continuously increasing but there are some ID's missing like 11,14,15,16,17,20,21.. etc

    Thanks
    Funny Reviewed by Funny on . SQL Help This is a easy code but I am not able to figure it as Im fairly new to SQL. Example I have a table like this- Name: ID: abcde 1 efghia 3 pofjsa 5 asklda 6 I want to sort the tables according to increasing ID. Rating: 5

  2.   Sponsored Links

  3.     
    #2
    Respected Member
    Website's:
    DL4Everything.com Soft2050.in
    Simply use ORDER BY column_name here in your sql query

    Example:
    PHP Code: 
    SELECT FROM mysecrettable ORDER BY names 

  4.     
    #3
    Respected Developer
    Website's:
    wrzc.org
    Just to add to the above you can have ORDER BY something DESC or ORDER BY something ASC
    which means you can have it decreasing (DESC) or ascending (ASC)
    Tutorial How to SEO your Warez Site a guide to help you increase your organic traffic

    Huge list of Warez Sites and free Multiposter Templates

  5.     
    #4
    Respected Member
    I believe soft meant to say :

    PHP Code: 
    SELECT FROM mysecrettable ORDER BY id asc 

  6.     
    #5
    Respected Member
    Website's:
    DL4Everything.com Soft2050.in
    nah
    That would make it from ascending order of the id of the column
    Specifying the name of the field would result in the data output in acending order of the column.

    http://php.about.com/od/learnmysql/p/SQL_order_by.htm

  7.     
    #6
    Respected Member
    Quote Originally Posted by funny5293 View Post
    This is a easy code but I am not able to figure it as Im fairly new to SQL.

    Example I have a table like this-
    Name: ID:
    abcde 1
    efghia 3
    pofjsa 5
    asklda 6

    I want to sort the tables according to increasing ID.
    Like this-
    Name: ID:
    abcde 1
    efghia 2
    pofjsa 3
    asklda 4


    Assuming that the ID's are continuously increasing but there are some ID's missing like 11,14,15,16,17,20,21.. etc

    Thanks
    He said he wanted it by id. check his quote again.

    And I guess you can use this link http://php.about.com/od/learnmysql/p/SQL_order_by.htm and one for reading http://www.rif.org/

  8.     
    #7
    Member
    Website's:
    FunLinkz.com Smyu.in
    Thank you for the help guys.

  9.     
    #8
    Member
    Website's:
    FunLinkz.com Smyu.in
    Now I have another question-
    I want to update a column in my sql but I think I got the syntax wrong-
    UPDATE `url` SET `destination`="http://"+`destination` WHERE `destination` NOT LIKE 'http%'
    It sets destination as 0 instead of http://+destination..

  10.     
    #9
    Member
    Website's:
    sborg.us
    Use || for concatenating strings

    UPDATE `url` SET `destination`='http://'||`destination` WHERE `destination` NOT LIKE 'http%'

    V3g3ta | Halcyon | Abhi

  11.     
    #10
    Respected Member
    You are welcome and for the update..
    try this one:
    PHP Code: 
    UPDATE `urlSET `destination`=concat("http://",`destination`) WHERE `destinationNOT LIKE 'http%' 
    PS backticks are a pain and most systems work without them.

    so it could be simply:
    PHP Code: 
    UPDATE url SET destination=concat("http://",destinationWHERE destination NOT LIKE 'http%' 
    BY the way when you use + mysql tries to add..

    when you use || it means or not concat...

Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

BE SOCIAL