doudi2431 2011-11-05 21:36
浏览 9

where field1 + field2 + field3 LIKE“%my_own_string%”?

I have a string, like Elton 1999, and a MySql table with 4 fields :

table(id, name, surname, year)

I have to check if, joining these fields as "single field", it contains all the words of my string.

I mean :

1 Elton John 1999 -> must return the record
2 Elton Peter 1999 -> must return the record
3 Paris Elton 1999 -> must return the record
4 Elto John 1999 -> must not return the record
5 Elton Pierre 2000 -> must not return the record

Can I do it directly with MySql or I need first to get all the records and than parse them on server side? (on PHP, in my case)

P.S. The same result must begin if my string is 1999 Elton, so the order of my words doesnt matter...

  • 写回答

2条回答 默认 最新

  • dtufl26404 2011-11-05 21:39
    关注

    As long as your input strings are consistently formatted, you should be able to join the fields together using CONCAT_WS() with a space as the separator and compare them to your input string when querying.

    评论

报告相同问题?

悬赏问题

  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大