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
MySQL Server

Avatar of undefined
Last Comment
PortletPaul

8/22/2022 - Mon
SOLUTION
Mark Bullock

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
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
PortletPaul

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
PortletPaul

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy