1

I have a SQL query:

select recipe_title
             from recipe where
             meal_type ='BREAKFAST'

Is it possible to match any meal_type by only change the BREAKFAST?

Such as:
    select recipe_title
                 from recipe where
                 meal_type = *

I know I can use like %% but that will need to change many places in my code. Is it possible to get all meal_type and still use =

Thanks!

2
  • Is the ? in the question a placeholder or just that you want use the = operator? Can you expand how this is being used in your code? Commented May 29, 2020 at 0:31
  • I just want to use = operator Commented May 29, 2020 at 0:38

1 Answer 1

2

No. = is an equality operator. The best you can do is WHERE meal_type = ANY('{BREAKFAST,LUNCH,DINNER}'), iff you have a known short list of all possible values, but there's no wildcard-like behavior with =. The correct way of doing this (returning all rows regardless of meal_type) is to not have a meal_type = <whatever> in your WHERE clause.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.