Link to home
Start Free TrialLog in
Avatar of srikotesh
srikotesh

asked on

how do i simplify the below my sql query

Hi Experts,

can some one suggest me alternative or condition in the below query.
i want to convert this query to hibernate hql query.

e.uid like '%SSL%' OR e.title like '%SSL%' OR e.description like '%SSL%' OR e.customkeywords like '%SSL%' OR t.kb_entry_attributes LIKE '%SSL%')

query:
======
select t.id,t.name FROM entry_attributes t  
INNER JOIN entry as e ON (t.kb_id=e.id) AND (e.uid like '%SSL%' OR e.title like '%SSL%' OR e.description like '%SSL%' OR e.customkeywords like '%SSL%' OR t.kb_entry_attributes LIKE '%SSL%')
LEFT OUTER JOIN entry_source es ON (es.kb_id=e.id) AND (es.ticket_id=0)

thanks
SOLUTION
Avatar of Mark Bullock
Mark Bullock
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of srikotesh
srikotesh

ASKER

I have to remove that or condition
after and condition or is there multiple times
because of or condition iam unable to change sql query to hql hibernare
is there any alternative for or condition
Mark, that is not an equivalent query

original
LEFT OUTER JOIN entry_source es ON (es.kb_id=e.id) AND (es.ticket_id=0)

If you move this (es.ticket_id=0) condition into the where clause you override the left join and form an "implied inner join" you have to also allow for NULL to preserve the left join, like this

WHERE ( es.ticket_id=0 OR es.ticket_id IS NULL )
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial