我有一些sql代码:
$id = "2000";
$model = $_GET["model"]
$result = mysql_query("SELECT
Left(Right(Base.inputs.Data_inf,4),3) As 'Datas',
count(Base.Data.Data_ID) As `U_Count`
FROM
Base.Data
WHERE
Product = '$id'
AND model in ('a','b','c')
GROUP BY ");
我想让查询的 AND 部分成为动态的。像这样的东西:
$m= $model;
switch ($m)
{
case "basic":
$m = "AND model in ('a','b','c')";
break;
case "upgrade":
$m = "AND model in ('d','e','f')";
break;
default:
$m = "AND model in ('a','b','c')";
}
我将 $m 放入查询中,但它不起作用:
WHERE
Product = '$id'
'$m'
任何建议将不胜感激。