select * from table where content like '%商店名字%'

解决方案 »

  1.   

    接楼上,如果不能实现你所谓的模糊查询。。只能自定义一个split函数了。。你可以查下mysql split()。相信能解决你的问题。
      

  2.   


    我不太懂你意思哎,你table是content吧?那没有属性名?比如商店名字是shop_name之类的?
      

  3.   

    问题就在这里...商店的属性并没有单独的字段,都是按照格式存在content的字段里面
      

  4.   

    这样行吗
    slect * from A where content like "%=商店名字|%"
      

  5.   

    表设计的有点难度...
      如果数据量不大
      办法就是取出全部的content 
      然后再根据"|" 拆分成数组...
      然后再来对比...
      

  6.   


    在mysql里写个方法吧 你的记录里 所有等号后面都是商店名字在方法里查找
      

  7.   

    <?php include "conn/conn.php";?>
    <?php
    if($_POST["submit"]<>""){
    $txt_tj=trim($_POST["txt_tj"]);
                $strs=explode("*",$txt_tj);
             while(list($name,$value)=each($strs)){
    $sql=mysql_query("select * from tb_book where synopsis like '%$value%' or bookname like '%$value%' order by id desc");
    $info=mysql_fetch_array($sql);
    }}
    if($info){
    do{
    ?>
              <tr>
                <td height="23"><span class="STYLE1">&nbsp;◎&nbsp;
                <?php 
    $string=str_ireplace($txt_tj,"<font color='#FF0000'><strong>$txt_tj</strong></font>",$info[bookname]);
    echo $string;
    ?>
                </span></td>
              </tr>
              <tr>
                <td height="22" class="STYLE1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?php 
    $strings=$_POST["txt_tj"];
    $string=str_ireplace($_POST["txt_tj"],"<font color='#FF0000'><strong>$strings</strong></font>",$info[synopsis]);
    echo $string;
    ?></td>
              </tr>
      <?php }while($info=mysql_fetch_array($sql));
      }else{
      ?>
      <tr>
      <td><span class="STYLE2">对不起,您检索的信息不存在!</span></td>
      </tr>
      <?php  }  ?>
          </table>     
          <br></td>
        </tr>
      </table>
      

  8.   

    sql查询语句里加正则表达式可以解决
    例如:select * from table where content REGEXP ''具体的正则我不会写,你可以上网搜索一下。
      

  9.   

    大概应该是这样:
    select * from table where content REGEXP '^[|{$xxx}|]$'
    {$xxx} 这个是你的查询变量这个正则的意思是模糊匹配 第一个“|”到第二个“|”之间的内容与查询变量进行匹配。
    我也不知道这个正则写的对不对,大体是这个意思,你再去搜搜。
      

  10.   

    select * from table where content REGEXP '^|{$xxx}|$'
    这个是对的
      

  11.   

    表结构的设计也太牛叉了吧,第一次看到这样设计的.如果为了以后的方便最好现在就改表结构,
    我想到的笨方法:select * from table where content like '%商店名字%'这样查询个大概,
    然后再在程序里面去遍历数组判断...