MySQL Forums
Forum List  »  Newbie

Re: Selecting specified values from different coulmns
Posted by: Shawn Green
Date: October 07, 2022 01:51PM

To get the second output, change the OR in your WHERE clause to an AND. Then both columns must have the substring "ball" in their values for that expression to become true.

If you a need a simple single-column list of all the values from game1 and game2 listing any value with "ball" in it, you will need to use the UNION operator to combine the results of separate queries into a single result.

SELECT game1 from sports where game1 like '%ball%'
UNION
SELECT game2 from sports where game2 like '%ball%'

Options: ReplyQuote


Subject
Written By
Posted
Re: Selecting specified values from different coulmns
October 07, 2022 01:51PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.