duanbai1370 2011-07-21 09:24
浏览 59
已采纳

PHP搜索功能在pgsql表中查找

I want to make a search function in my website. I want to search for a string in all fields of my table (about 13 columns). If one row contains a field that matches the string (like operator) I want it to be added to result.

Example

|field 1 | field 2 | field 3|
 some      string     test    
 test      some      string
 one       simple    string

Now basically if I search for the string "test" I want to have the first two rows.

Is there a wildcard option for WHERE that I could do something :

SELECT * from my.table WHERE * like '%string%';

  • 写回答

1条回答 默认 最新

  • dsgk0386 2011-07-21 10:02
    关注

    There is no such syntax in PostgreSQL (or any other DBMS).

    As Spudley pointed out using a query like like '%string%' will be quite slow.

    If this is something that is needed very often you should definitely look into PostgreSQL's full text search capabilities.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?