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 stata安慰剂检验作图但是真实值不出现在图上
  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题