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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PHP with SQL Query

Status
Not open for further replies.

ranms

Technical User
Jun 9, 2003
7
DE
Rather an SQL Question...
How can I search in a field with many words for one single keyword? like, when the field contains - apple, banana, pear, plum- , and i am just searching for - pear - ?

... WHERE field LIKE '% Keyword %' , which was my only idea, (i am a newbie) didnt yeald much success!?
Thank you very much for ideas and suggestions,
R
 
Insufficient data for a meaningful answer -- you did not specify which of the plethora of PHP-supported databases you are using. I will assume MySQL.

The LIKE operator should have done it for you. What does "didn't yield much success" mean in this context?

Want the best answers? Ask the best questions: TANSTAAFL!
 
hi, yea probably I shouldnt have posted 2wice, but i didnt know wich forum fit best.
Also, quite right, LIKE did work.
the error was in my code.
But here is another question!
how do I search my query results from the first query with a second query?
Is this a stupid beginners question? I hope not.
If yes, please someone be so kind as to direct me to a good tutorial, and i will rtfm.
Thank you, R
PS Indeed i am using SQl MySQL and PHP
 
ranms:
It is possible to perform a selection from a database into a temporary table, then perform your second query against the temporary table.

However it's often not necessary to go to that extreme -- often two queries can be combined into a single query.

For example, suppose you needed to answer the question "How many cars in the inventory are both convertible and red?". You could perform a query pulling out all convertibles to a temporary table, then perform a second query which pulls out all the records for red cars from that table.

You can also perform a single query like, "SELECT * from cars where is_convertible = 'Y' and color = 'red'"

Want the best answers? Ask the best questions: TANSTAAFL!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top