×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Advanced search with MySQL

Advanced search with MySQL

Advanced search with MySQL

(OP)
Hi !


How can i make advanced search with MySQL ?

If i have in STAFF -table value James Smith, how can i find that if i search using searchword 'Smi' or 'jame' ???

I have now code like this:

$query="SELECT * FROM staff WHERE ID = '$searchword' OR Name = '$searchword' OR Email = '$searchword' OR Telephone = '$searchword' ORDER BY Name";



Thx !!

RE: Advanced search with MySQL

A short example

$searchword = "Smi";

$query="SELECT * FROM staff WHERE ID LIKE '$searchword%';

The above would find any record where the ID column starts with "Smi".

$query="SELECT * FROM staff WHERE ID LIKE '%$searchword%';

This would find any record where the ID column contains "Smi" somewhere. The % is like the * wildcard when doing file searches, it can match any number of characters. There are a lot of other operators that let you do more specific things, though.

I can show you a quick way to deal with a specific instance, but I cannot do your homework for you. If you want to use MySQL to even one-fiftieth of its capability, you need to learn some basic SQL.

There are some excellent MySQL tutorials available at Devshed (http://www.devshed.com/Server_Side/MySQL/), and plenty more available at www.phpbuilder.com, just to name a few. I recommend starting with "Speaking SQL", Parts I and II at Devshed, then browsing around for more sophisticated stuff.

I also recommend the Oreilly book "MySQL and mSQL" for a nice database intro that presents things concisely, without giving you too much to chew on at any one time. (http://www.oreilly.com/catalog/msql/)

Have fun learning

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close