Ask Your Question

2 word query for same field

asked 2017-09-23 15:30:27 +0200

Spur52 gravatar image

I have a recipe database. 2 fields (Recipe Name and Ingredients). I want to query Recipe Name using 2 words and also query Ingredients. Example: asian salad in Recipe Name and lettuce in Ingredient. Using the formula below it works well using one word but how to search using 2 words?

SELECT * FROM "Recipe Table" WHERE "Recipe Name" LIKE '%' || :Enter_Search_Word || '%'
AND "Ingredients" LIKE '%' || :Enter_Search_Word || '%'

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted

answered 2017-09-23 16:13:42 +0200

Ratslinger gravatar image

updated 2017-09-24 01:58:42 +0200

If you are looking for the two words to be together in the recipe name, such as 'asian salad', there is nothing to do. Just enter in the first parameter prompt. If looking for 'asian' and 'salad' to be individually anywhere in the recipe name then just add another item in the WHERE statement:

SELECT * FROM "Recipe Table" WHERE "Recipe Name" LIKE '%' || :Enter_Recipe_Word_A || '%'  AND 
"Recipe Name" LIKE '%' || :Enter_Recipe_Word_B || '%' AND   "Ingredients" LIKE '%' || :Enter_Ingredients_Word || '%'
edit flag offensive delete link more


Thanks for getting back to me. I tried that and it only asked " :Enter_Search_Word" once

Spur52 gravatar imageSpur52 ( 2017-09-24 01:24:23 +0200 )edit

Sorry. Only based it upon your original post and thought you knew how parameters worked. Each :Enter_Search_Word will use the same input wherever used. To have three different input parameters they each need to be spelled differently such as :Enter_Recipe_Word_A, :Enter_Recipe_Word_B, :Enter_Ingredients_Word.

Ratslinger gravatar imageRatslinger ( 2017-09-24 01:57:07 +0200 )edit

Thanks Ratslinger. I am new to SQL and love it. Just have to learn the lingo, etc. Help like you make it easier.

Spur52 gravatar imageSpur52 ( 2017-09-24 17:59:50 +0200 )edit

If this answers your question please click on the ✔ (upper left area of answer).

Ratslinger gravatar imageRatslinger ( 2017-09-24 20:58:35 +0200 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2017-09-23 15:30:27 +0200

Seen: 41 times

Last updated: Sep 24 '17