首页 > 编程知识 正文

数据库查询包含某个值的表,sql查询字段包含数字和字母

时间:2023-05-05 00:30:13 阅读:130482 作者:4928

I ' vebeentryingtofigureouthowicanmakeaquerywithmysqlthatchecksifthevalue (string $ haystack ) inacertaincolumncontainscertataion

mysql_query ('

选择*

从表

where ` column `.contains ({ $ needle } ) )

();

In PHP,thefunctioniscalledsubstr ($ haystack,$needle ),so maybe:

WHERE substr(`column `,' {$needle} ' )=1

Quite simple actually:

mysql_query ('

选择*

从表

WHERE `column` LIKE '%{$needle}% '

();

the % isawildcardforanycharactersset (none,one or many ).donotethatthiscangetslowonverylargedatasetsssoifyourdatabasegrowsegrowsyowsyoyograteted

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。