php mysql的char和int问题

SELECT * FROM dbase where type=substr("type=1",5);//这句查不到结果
SELECT * FROM dbase where type=1;//这句能查出正确结果

type在表dbase中是int类型
在mysql中好像是可以char和int比较的啊?
“type=1”为上一页面传递参数切割后的字符串$ids
echo substr($ids,5)显示也为1;
但SELECT * FROM dbase where type=substr($ids,5);的执行结果却是空,没有把数据库中type=1的显示出来

又用
SELECT * FROM dbase where type=convert(substr("type=1",5),int);
SELECT * FROM dbase where type=cost(substr("type=1",5) AS int);
都是错误的,怎么回事呢,怎么处理呢?

谢谢各位,过渡一下凑合解决了
$a=substr($ids,5);
SELECT * FROM dbase where type=$a;

第1个回答  2009-01-18
mysql支持隐式的常见类型的转换,早期的数据库必须明确转换到列相同的类型才能取出想要的结果
第2个回答  2009-01-19
$sql="SELECT * FROM `dbase` where `type`='".substr("type=1",5)."'";

把 $sql 发送出去执行吧。本回答被提问者采纳
第3个回答  2009-01-19
echo $sql,
var_dump
这是最基础的Debug方法