Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

String matching 1

Status
Not open for further replies.

DeepBlerg

Technical User
Jan 13, 2001
224
AU
Hi,

If i have the following table:

--------------
| ID | Color |
--------------
| 1 | Blue |
| 2 | Red |
--------------

If I have a HTML form and the user inputs in a textfield "The sky is usually blue in color".

How do I do a query where I want ID 1 returned?
 
Do you mean you want to return the ids of all records where the color field value appears in the textfield?

If so, how about:
[tt]
SELECT id FROM tbl WHERE textfld LIKE CONCAT('%',color,'%')
[/tt]


-----
ALTER world DROP injustice, ADD peace;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top