0

我在 Stackoverflow 上看到了其他一些讨论子选择的问题,但它们通常与使用多个表有关。在大多数情况下,正确的连接可以达到相同的目的。

但是我下面的查询是指一个表。我将如何使用 DBIX::Class 编写它?

select  ID, username, email, role
from Employees
where (ID in 
    (select max(ID)
        from Employees
        where username = 'jsmith'
    ))
order by ID DESC

谢谢!

-- 编辑 1:SQL 代码修复

4

1 回答 1

1

The Cookbook has almost the exact same query as example.

Your SQL query doesn't make sense to me because the subquery returns a single id, so WHERE id = () would make more sense. What are you trying to accomplish with it?

于 2012-08-17T22:54:18.583 回答