我试图在phpMyAdmin上使用相交查询,但显然它不支持INTERSECT,至少我敢肯定它不支持。这是我要使用的查询,但是可以将其放入不使用INTERSECT的位置的另一种方法是什么?

SELECT cust_code, cust_fname, cust_lname
FROM lgcustomer join lginvoice USING (cust_code) WHERE employee_id = 83649
INTERSECT
SELECT cust_code, cust_fname, cust_lname
FROM lgcustomer join lginvoice USING (cust_code) WHERE employee_id = 83677
ORDER BY cust_lname, cust_fname;

最佳答案

没错,MySQL不支持INTERSECT。

SELECT cust_code, cust_fname, cust_lname
FROM lgcustomer join lginvoice USING (cust_code)
WHERE employee_id IN (83649, 83677)
GROUP BY cust_code, cust_fname, cust_lname
HAVING COUNT(DISTINCT employee_id) = 2

关于mysql - 用phpMyAdmin替换INTERSECT,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/43123809/

10-14 14:57