本文介绍了挣扎于自定义 SQL 查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须查询:

显示一个视图,显示每个员工区域的所有员工奉献的计数结果,按区域名称按字母顺序列出.

show a view which shows the results of counting all the employee dedications per employee area, listed by the area names in alphabetical order.

$this->db->query('create temporary table temp as (select dedication.employee_employeeID, dedication ID, COUNT(area) AS TotalFrequency from dedication, employees where dedication.employee_employeeID = dedication group by dedication.employee_employeeID)');

但是,我的网站似乎不起作用?

However, doesn't seem to be working on my website?

这是我的人际关系:

在此处输入图片说明

推荐答案

我建议这样编写查询:

create temporary table temp as
    select c.industry, count(*) AS TotalFrequency
    from interest i JOIN
         customers c
         on i.staff_staffID = c.interestID
    group by c.industry;

这只是猜测.您尚未提供表格布局.join 条件很奇怪(但不会导致错误,只是不匹配).

This is just a guess. You haven't provided table layouts. The join conditions are quite strange (but wouldn't result in an error, just non-matches).

这篇关于挣扎于自定义 SQL 查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-16 15:41