Computing.Net > Forums > Database > MySQL Partial Search

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

MySQL Partial Search

Reply to Message Icon

Name: RTAdams89
Date: May 20, 2008 at 02:38:35 Pacific
OS: na
CPU/Ram: na
Product: na
Comment:

I have a MySQL table which contains a column with names in it. I am using the following to search for and return any rows with the name entered into a html form on my site. This works fine as long as the exact name is entered into the form.

mysql_query("SELECT * FROM invoices WHERE name='" . $_POST["name"] . "'")

However, I would like to be able to return results that are partial matches. For example, if one of the names in the MySQL table is "Joe's Auto Shop", I would like to have that row returned even if only "Joe" is entered into the html form. Can this be down easily?

-Ryan Adams
http://RyanTAdams.com



Sponsored Link
Ads by Google

Response Number 1
Name: FishMonger
Date: May 20, 2008 at 09:03:16 Pacific
Reply:

mysql_query("SELECT * FROM invoices WHERE name like '" . $_POST["name"] . "%'")


0
Reply to Message Icon

Related Posts

See More


Can I import simply Acc. ... Swap contend of 2 rows in...



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Database Forum Home


Sponsored links

Ads by Google


Results for: MySQL Partial Search

MySQL Client GUI suggestions www.computing.net/answers/dbase/mysql-client-gui-suggestions/207.html

MySQL Select multiple tables www.computing.net/answers/dbase/mysql-select-multiple-tables/158.html

SQL text search loop www.computing.net/answers/dbase/sql-text-search-loop/431.html