【问题标题】:How to set column value as variable in msaccess php如何在msaccess php中将列值设置为变量
【发布时间】:2016-07-04 15:09:01
【问题描述】:

我的查询:

$att="select
      AttData.Rollno,AttData.Name,AttData.Year,AttData.sec,AttData.".$date." 
      from AttData where AttData.sec='".$sec."' and AttData.dept='".$dept."' 
      and  AttData.year='".$year."' and AttData".$date."='AB'  ";

我的数据库设计视图是

我的错误

警告:odbc_exec() [function.odbc-exec]:SQL 错误:[Microsoft][ODBC Microsoft Access 驱动程序] 查询中的语法错误(缺少运算符) 表达式 'AttData.sec='A' 和 AttData.dept='cse' 和 AttData.year='IV' and AttData'02-07-2016'='AB' ''., SQL state 37000 in SQLExecDirect 在 C:\wamp\www\sms1.7.16\repotdaygen_allyear.php 上线 325 选择无效37000

【问题讨论】:

  • 你的问题可能是and AttData".$date."='AB',它变成了and AttData'02-07-2016'='AB' 。不知道你想做什么,但像这样这是完全错误的。处理“AB”值的列的名称是什么? (我无法从工作中打开图像...)
  • 你需要一个空间
  • 列名是'02-07-2016',值是AB或P

标签: php mysql sql-server


【解决方案1】:

试试这个...我在 $date 周围的两个位置添加了方括号

$att="select
      AttData.Rollno,AttData.Name,AttData.Year,AttData.sec,AttData.[".$date."] 
      from AttData where AttData.sec='".$sec."' and AttData.dept='".$dept."' 
      and  AttData.year='".$year."' and AttData[".$date."]='AB'  ";

【讨论】:

    猜你喜欢
    • 2013-06-05
    • 1970-01-01
    • 1970-01-01
    • 2021-04-03
    • 2021-07-14
    • 1970-01-01
    • 2023-03-24
    • 1970-01-01
    • 2019-03-10
    相关资源
    最近更新 更多