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 4 of 4

Thread: Query Question

  1. #1
    Regular Coder
    Join Date
    May 2010
    Posts
    224
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Query Question

    Let say I have this stored in my database. "ROOSEVELT COLLEGE - SAN MATEO - STU" And i want to retrieve this with words using this as my search "ROOSEVELT COLLEGE SAN MATEO".

    something like this
    PHP Code:
    select [column namefrom [databasewhere word="ROOSEVELT COLLEGE SAN MATEO" 
    after this query it should retrieve ROOSEVELT COLLEGE - SAN MATEO - STU

    Is this possible using regex or like? Thanks.

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,865
    Thanks
    160
    Thanked 2,224 Times in 2,211 Posts
    Is this possible using regex or like? Thanks.
    Yes, it's quite easy if you use mySQL's full text search

    Check the mysql manual for more info
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    Regular Coder
    Join Date
    May 2010
    Posts
    224
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks for the answer. I have trouble putting the proper syntax on php.

    What is the proper syntax of this with php code?

    SELECT *
    FROM products
    WHERE MATCH(desc)
    AGAINST('"iphone 4s"' IN BOOLEAN MODE)

    something like $sql=" sql line here ";

    Also does this work on mssql_query extension?

  • #4
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,642
    Thanks
    0
    Thanked 649 Times in 639 Posts
    mysqli_query($conn,"SELECT * FROM products WHERE MATCH(desc) AGAINST('phone 4s' IN BOOLEAN MODE)")
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.


  •  

    Posting Permissions

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