oracle 关联查询 查询自身表

字段:


效果:

本来是select * from table 但是由于关联了一个別的表的字段,重写下查询语句效果和select * 一样,特此记录一下:

		StringBuffer hql=new StringBuffer();
		hql.append("select w.id as \"id\",w.title as \"title\",w.classification as \"classification\",w.keyword as \"keyword\",w.clicks as \"clicks\",w.committime as \"committime\",w.status as \"status\",w.contentss as \"contentss\" ");
//		hql.append(" from knowledge w where 1=1 ");

		hql.append("  from (select k.* from knowledge k inner join  CLASSIFICATION c on k.classification=c.classification  ");
		String classification = workOrderTDTO.getClassification();
        if (null != classification && !"".equals(classification)) {
            hql.append(" where c.id=(select id from CLASSIFICATION a where a.classification like'%").append(classification).append("%')");
            hql.append("  or c.id in(select p.id from CLASSIFICATION a inner join CLASSIFICATION p on a.id=p.perid  where a.classification like '%").append(classification).append("%')");
        }
		hql.append(" ) w where 1 = 1 ");



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值