Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Dec 2005
    Posts
    217
    Thanks
    1
    Thanked 0 Times in 0 Posts

    how to perform this query ??

    Hello forums!!
    Suppose i had the following table (with fields and values)
    table1
    -------------------------
    |id | name | description |
    -------------------------
    | 1 | 12 name1 bla1 | desc1 |
    | 2 | 13 name2 bla2 | desc2 |
    |...so on
    --------------------------
    My question is: How to perform the query if i would like to fetch the row which matches the no (which is in conjuction with the name followed by space) with the passed no ie
    PHP Code:
    $query  "SELECT * FROM `table1` WHERE [no part of the name ie 12] = [passed no ie 12]"
    Any suggestions , tips are warmly welcome
    Thanks in advance to all of you !!
    Last edited by PHPycho; 03-30-2007 at 08:34 AM.

  • #2
    Regular Coder
    Join Date
    Mar 2007
    Posts
    505
    Thanks
    1
    Thanked 19 Times in 19 Posts
    Try:

    Code:
    $query = "SELECT * FROM `table1` WHERE InStr(Name,'" + $var + "');"
    $var = "12"

    That will pull all records with "12" in the name

    HTH!


  •  

    Posting Permissions

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