例如:
   数据库有个 字段   citys    
              值是  122,456,23     数字代表了城市 122=>'北京',456=>'上海',23=>'广州',   $cityid=$_GET[cityid];//获取到的城市id   查询(有没有类似下面的语句)   select * from table where $cityid in (citys);//这个有问题
   
   有没有什么语句能实现   

解决方案 »

  1.   

    $cityid in (citys)where citys = $cityid  //cityid 只有一个的情况下
    where citys IN (id1,id2,id3....) //多个id
      

  2.   

    select * from table where $cityid in (citys);
    这句可以直接用的
      

  3.   


    好像不行啊,这种只能查到第一个的(当$cityid=122)的时候
      

  4.   

    where后面的数据库字段应该是确定的,而不应该是变量(因为如果不存在这个字段的话会导致查询错误)select * from table_name where citys = '$cityid';查询失败结果为false表示不存在相应的city
      

  5.   

    select * from a where FIND_IN_SET (7,content);