Home > Backend Development > PHP Tutorial > PHP+MYSQL怎么查询数据库里面符合条件的列。

PHP+MYSQL怎么查询数据库里面符合条件的列。

WBOY
Release: 2016-06-23 13:59:10
Original
945 people have browsed it

我的A表的内容格式是这样的。

字段aa           字段bb                      字段cc
   1            ,000,001,008                   100
   2           ,000,002,003,008             30
   3            ,000,012,008                    20
   4            ,000,008,222                    55
   5            ,000,008,138                    33
 
我需要查询列出只要符合最后三位数字为008的数据。在中间和前面都不行。必须是最后三位。

用PHP+MYSQL语句怎么写?
我这样写不对。出错。。不知道怎么弄了。求教我。
SELECT * FROM A WHERE cc LIKE '__008'


回复讨论(解决方案)

这样呢?SELECT * FROM A WHERE cc LIKE '%,008';

再试试SELECT * FROM A WHERE substring(bb,0,-3) ='008';

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template