select usercode,(select username from USER u where u.usercode = ps.usercode) as username from PERSON ps where 1=1;
[quote=引用 1 楼 u011213572 的回复:] 把USER、PERSON代码贴出来,看下他们的关系,才能给你答案
select usercode,username as un from PERSON ps,USER u where u.usercode = ps.usercode, 看了半天感觉你的hql写的怪怪的,然后又看了版主的回复其实就是这么easy
person里会有(select username from USER u where u.usercode = ps.usercode)这个结果字段吗?联合查询不就行了。
把USER、PERSON代码贴出来,看下他们的关系,才能给你答案
67,512
社区成员
225,885
社区内容
加载中
试试用AI创作助手写篇文章吧