在我的数据库中,我有两个表:
视野中的结果需要像这样的结果:
*****************************
subject * sub-subject * dep *
*****************************
sub_1 * sub sub1 * 1 *
*********************
* sub sub2 * 2 *
*****************************
sub_2 * sub sub 4 * 1 *
*****************************
sub_3 * sub sub 3 * 1 *
*********************
* sub sub 5 * 2 *
*********************
* sub sub 6 * 2 *
*****************************
我使用此查询从此表中获取DB表:
SELECT
CASE WHEN t.id = (SELECT id -- Sub query
FROM sub_subjects t3
WHERE t3.subject_id = t.subject_id
ORDER BY t3.id
LIMIT 1) THEN q.description
ELSE ''
END AS subjects, t.description AS sub_subjects, t.department_id
FROM sub_subjects t
LEFT JOIN subjects q ON q.id = t.subject_id
ORDER BY t.id
如何在java spring中传递此表?有办法获得子行吗?
谢谢!
答案 0 :(得分:0)
不确定这个问题与春天有关。 为了获得表实体,你应该使用jdbc或orm,例如hibernate with manytomany relation