'How to say or in MySQL statement
I'm trying to match two choices. "One or the other"
SELECT * FROM course WHERE category='blue' || category='red' ORDER BY id DESC LIMIT 5
That is my first thought is to use
||
Solution 1:[1]
SQL does support logical operators as well.
By the way, you can shorten this statement to
SELECT * FROM course WHERE category IN ('blue','red') ORDER BY id DESC LIMIT 5
Solution 2:[2]
use the word or instead of ||.
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 | Dharman |
| Solution 2 | laalto |
