douji5397 2016-09-15 16:07
浏览 128

我的问题是什么? 将varchar转换为数据类型int时转换失败

I keep getting the error: Conversion failed when converting the varchar value ' BUY0' to data type int, I am unsure what the issue with my code is. the column type for cd_tp_1_item_no is varchar(30)

$customers = array("4470","3650","4322");

foreach($customers as $customer){

$sql = "SELECT DISTINCT cd_tp_1_item_no FROM oeprcfil_sql where cd_tp_1_cust_no = $customer";
$result = odbc_exec($conn,$sql);
$item[] = "";
        while ($row = odbc_fetch_array($result)) {

             $item = $row['cd_tp_1_item_no'];

    }


}
  • 写回答

1条回答 默认 最新

  • donglang9880 2016-09-15 16:27
    关注

    You can use next suggestion to fix your issue:

    $sql = "SELECT DISTINCT cd_tp_1_item_no FROM oeprcfil_sql where cd_tp_1_cust_no = '".(int)$customer."'";
    
    评论

报告相同问题?

悬赏问题

  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作