Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/72.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
比较MySQL中的变量和数组_Mysql_Arrays_Database_Serialization - Fatal编程技术网

比较MySQL中的变量和数组

比较MySQL中的变量和数组,mysql,arrays,database,serialization,Mysql,Arrays,Database,Serialization,我在MySQL中有多行,有两列:ID,CatID 特别是,我对CatID的变量使用了serialize()函数来转换数组并将数据存储到数据库中 现在,我有一个变量(例如:CatID=98),我想将它与数据库中的数组进行比较。我需要什么SQL查询?我怎么写 数据库中的数组示例:a:2:{i:0;s:2:98;i:1;s:2:99;} 编写数据库查询。如果您的数组类似于a[1]=“something”,希望您能对它们进行比较 CatID列存储了一个字符串a:2:{i:0;s:2:“98”;i:1;s

我在MySQL中有多行,有两列:ID,CatID

特别是,我对CatID的变量使用了
serialize()
函数来转换数组并将数据存储到数据库中

现在,我有一个变量(例如:CatID=98),我想将它与数据库中的数组进行比较。我需要什么SQL查询?我怎么写

数据库中的数组示例:
a:2:{i:0;s:2:98;i:1;s:2:99;}


编写数据库查询。如果您的数组类似于
a[1]=“something”
,希望您能对它们进行比较

CatID列存储了一个字符串
a:2:{i:0;s:2:“98”;i:1;s:2:“99”}
-所以我尝试
$query=mysql\u query(“从我的数据库中选择*,其中CatID=98”)但不起作用:(“空结果”
echo“”;打印(urarray);echo“”;
打印数组并知道可以比较的索引。
   $query=mysql_query("SELECT CatID FROM UR_DB Where CatID=98"); 
   While($row==mysql_fetch_array($query))
   {
         $catid=$row['CatID'];
    }