'How can I include a row after a WHERE clause?
I have a list of names
- Bobby
- Owen
- Lilly
- Omar
- Justin
- Jamey
- Oden
I would like to first get only the names that begin with 'o' so I wrote
WHERE name LIKE 'O%'
Which gave me
- Owen
- Omar
- Oden
I would then like to add names that end with 'y'
- Owen
- Omar
- Oden
- Bobby
- Lilly
- Jamey
But I am having difficulty figuring out how to do so. I am working in oracle btw.
Solution 1:[1]
You could also use the AND:
`WHERE name LIKE 'O%' AND name LIKE '%y'`
Solution 2:[2]
SELECT * FROM MY_TABLE WHERE name LIKE 'O%'
UNION ALL
SELECT * FROM MY_TABLE WHERE name LIKE '%Y'
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Wanz |
| Solution 2 | Shaido |
