MYSQL错误1096-未使用任何表-CODENI [英] MYSQL ERROR 1096 - NO TABLES USED - CODEIGNITER

查看:421
本文介绍了MYSQL错误1096-未使用任何表-CODENI的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用自定义查询,因为Active Record等价物对我不起作用。

I am using a custom query as the Active Record equivelant did not work for me.

将查询放入我的数据库软件SQLYOG中后,它在CodeIgniter中可以正常工作它说

When placing the Query in my Database Software SQLYOG it works fine however in CodeIgniter it says


发生数据库错误

A Database Error Occurred

错误号:1096

未使用表

SELECT *

文件名:C :\xampp\htdocs\midas\系统\数据库\DB_driver.php

Filename: C:\xampp\htdocs\midas\system\database\DB_driver.php

行号:330

这是我的查询:

SELECT intervention.department_id, department_name, COUNT(*)
FROM intervention 
LEFT JOIN department ON department.department_id = intervention.department_id

GROUP BY intervention.department_id, department.department_name
ORDER BY COUNT(*) desc
LIMIT 1

这是一个奇怪的问题。

这也是我的架构:

http://i.imgur.com/mKNtc.png

推荐答案

编辑

这将不起作用。如下所述,仅 COUNT(*) COUNT(table.field)有效。

This will not work. As noted below only COUNT(*) or COUNT(table.field) work.

我认为您需要指定正在使用 COUNT(*)的表,因此将其更改为 COUNT(部门。*) COUNT(干预。*)

I think you need to specify which table you are using COUNT(*) on, so change it to something like COUNT(department.*) or COUNT(intervention.*)

这篇关于MYSQL错误1096-未使用任何表-CODENI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆