dsafew1231 2014-01-04 13:27
浏览 12
已采纳

我的SQL查询有什么问题?

I have a query that joins two table, and it keeps getting the error.

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '0' at line 1`.

I can't seem to figure out what is wrong here?

I've already check this but in my case it is different.

Here is my query:

$sQuery = "SELECT SQL_CALC_FOUND_ROWS A.id, A.studentNum, B.lastName, B.firstName, B.middleName, B.year, B.courseBlock, B.status, A.facultyloading_id"+
          " FROM table_enrolledstudents AS A"+
          " INNER JOIN table_student AS B"+
          " ON A.studentNum = B.studentNum";  

What do you think is wrong? Can you help me? Thank you!

  • 写回答

2条回答 默认 最新

  • dsnnvpobaljihv3490 2014-01-04 13:52
    关注

    Use the PHP string concatenation operator . (dot).

    Or to improve readability/maintainability you could also put the query into a single string with line breaks.

    $sql = "SELECT SQL_CALC_FOUND_ROWS A.id, A.studentNum, B.lastName, B.firstName, B.middleName, B.year, B.courseBlock, B.status, A.facultyloading_id
            FROM table_enrolledstudents AS A
            INNER JOIN table_student AS B
            ON A.studentNum = B.studentNum";
    

    Explanation: This is because PHPs type system allows arithmetic operations on strings (which can contain numbers), e.g. "1" + "2" would return the sum, which is 3. If a string used in an arithmetic operation does not contain a parsable number, then it is treated as zero, so the result of "abc" + 5 is 5.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算