我有2个类别
1.worker
2.staff
我有1行cardno
w12 (this is worker id format)
s109 and (this is staff id format)
我想只显示以s
字母
我该怎么做?
SELECT *
FROM accounts
where cardno
AND date BETWEEN '$a'
AND '$b'
order by date ASC
答案 0 :(得分:2)
您可以使用LIKE
子句:
SELECT *
FROM accounts
WHERE date BETWEEN '$a' AND '$b'
AND cardno LIKE 's%'
ORDER BY date ASC
答案 1 :(得分:1)
SELECT *
FROM accounts
WHERE cardno LIKE 's%'
AND DATE BETWEEN '$a' AND '$b'
ORDER BY DATE ASC
LIKE运算符用于在列中搜索指定的模式。 's%'表示以s开头的任何单词值。
答案 2 :(得分:0)
您可以使用LEFT
SELECT *
FROM accounts
WHERE
DATE BETWEEN '$a' AND '$b'
AND LEFT(cardno ,1) ='s' /* or S */
ORDER BY DATE ASC
返回字符串str中最左边的len个字符,如果是,则返回NULL 任何参数都是NULL。