开发者

Problem querying MySQL DB

I have this project I am开发者_C百科 working on, I have a table schema, see below

+--------+------------+------+-----+---------+----------------+
| Field  | Type       | Null | Key | Default | Extra          |
+--------+------------+------+-----+---------+----------------+
| codeId | int(15)    | NO   | PRI | NULL    | auto_increment |
| code   | varchar(9) | YES  |     | NULL    |                |
| status | varchar(5) | YES  |     | 0       |                |
+--------+------------+------+-----+---------+----------------+

This table is used for authorizations of codes, however some people send codes like dsfffMUBBDG345qwewqe for authorization, please note the capitalized part. In the code column there is a code MUBBDG345. I need to be able to check from the table if any combination of 9 characters the codes sent matches any of the codes in the db.

I have tried using this query but i just does not work.

select code, codeId, status from authCodes where 'dsfffMUBBDG345qwewqe' like code;

Is this even possible with a mysql query only?


you want to use

SELECT code, codeId, status
FROM authCodes
WHERE 'dsfffMUBBDG345qwewqe' LIKE CONCAT('%', code, '%')
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜