Web Analytics Made Easy -
StatCounter How to trim a string ! - CodingForum


No announcement yet.

How to trim a string !

  • Filter
  • Time
  • Show
Clear All
new posts

  • How to trim a string !

    I have a MYSQL database which has a student name, year and register number(rno) fields.

    In this rno filed length is 8 characters

    I use PHP with this query
    $result="select * from $tabname where RNO like '%$rno%'"

    My problem is, I have some hundred candidates whose register number length is only 4
    The regular length is 8 eg. 56001234

    Some have like this 1034

    How to get the rno for such candidates

    Please help

  • #2
    I don't see the problem.

    I see some other things though:
    - if the rno is alvaus anumerical valu, then you should have a numerical variable (an INT ), and not a stringvariable.
    - why do you need a like operator? Cant's you use an '=' operator?

    If you want to keep the values in a string-column, then it should be a varchar column, so VARCHAR(8)

    More info on columntypes
    Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html


    • #3
      Thanks I have solved it!
      Last edited by Raji; Feb 10, 2004, 07:27 AM.