ITeye博客

hql 多对多查询 elements

kaishiba · 2009-03-27 17:41 · hibernate · Blog · SQL · Markdown

可编写如下Hql 语句完成查询:

Sql代码

select Blog 
from Blog, Book
where Blog.author in elements(Book.authors)
	and Book.id=?

对应的Sql近似如下:

Sql代码

  1. select  blog.*
  2. from  blog, book
  3. where  (blog.author  in  ( select  author.authorid
  4. from  book_author
  5. where  book.id=book_author.bookid))
  6. and  book.id=?

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。