Reputation: 17566
Hi my table data look like this
mysql> SELECT * FROM user_details
-> ;
+----+----------+------+-----+
| ID | UserName | Type | Age |
+----+----------+------+-----+
| 2 | bandara | 2 | 26 |
| 3 | panama | 1 | 12 |
| 4 | sunil | 2 | 100 |
| 5 | aaa | 1 | 50 |
+----+----------+------+-----+
4 rows in set (0.00 sec)
iI used a wildcard to select all recods starting from either b or p , but the result set is empty , what i am doing wrong here , please help , thanks in advance.
mysql> SELECT * FROM user_details WHERE UserName LIKE '[bp]%';
Empty set (0.00 sec)
Upvotes: 0
Views: 172
Reputation: 12847
Another way is to use Regular Expressions :
SELECT * FROM user_details WHERE UserName REGEXP '^[bp]';
Upvotes: 1
Reputation: 635
Use code like this,
mysql> SELECT * FROM user_details WHERE (UserName LIKE 'b%') OR (UserName LIKE 'p%');
Upvotes: 1
Reputation: 18600
Try to remove bracket and put individual condition for b
and p
search tag like.
SELECT * FROM user_details WHERE UserName LIKE 'b%' OR UserName LIKE 'p%';
Upvotes: 1