Reputation: 310
I want to search question no. which can be 1, 1a, 1b, 2, 2c, 11. How can I to search 1 getting 1, 1a, 1b but not 11. And if I search 1b, only 1b comes out. Is there any function helps?
using mysql
DATA:
id |question |q_no.
1 |XX |1
2 |ABC |1a
3 |ED |1c
1 |CD |11
Desired sets:
when searching "1":
1 |XX |1
2 |ABC |1a
3 |ED |1c
when searching "1a":
2 |ABC |1a
sorry for being late
Upvotes: 0
Views: 40
Reputation: 1269445
I think regexp
is your best approach:
where question_no regexp concat('^', $SearchQ, '[^0-9]')
Upvotes: 1
Reputation: 116
May be this can help. It run in mysql.
SELECT---
FROM---
WHERE question_no REGEXP '1[^1]'
It will show question_no start with character '1' and followed by except character '1'
Upvotes: 1