我需要從數據庫中獲取一些數據。對於這個我寫的代碼像 try{
return (EmployeeImpl) em.createQuery(
"select e from EmployeeImpl e " +
"where e.empName = :employeeName " +
" and (e.eDate is null or e.eDate <=
我有'發佈'和'評論'表。我想選擇最後3個帖子和對該帖子的所有評論。我可以使用兩個單獨的語句: SELECT p.* FROM post p ORDER BY p.date DESC LIMIT 3; // called 1
SELECT c.* FROM comment c WHERE c.post_id = :id; // called 3x time for each post.
可以
如何限制只選擇一行的內部聯接或子查詢?在我的Sybase版本(Sybase版本:Adaptive Server Enterprise/15.5/EBF 19902)中,我無法在子查詢中使用'top 1'。 例 select * from A a
inner join B b on a.id = b.Aid
在該處表B具有兩個記錄鏈接到表A(相同助劑)。但我只想加入其中的一條記錄。 我試圖用子