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
LVL 2
srikoteshAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Mark BullockQA Engineer IIICommented:
I think this is simpler.
select t.id,t.name 
FROM entry_attributes t  
INNER JOIN entry as e ON (t.kb_id=e.id)
LEFT OUTER JOIN entry_source es ON (es.kb_id=e.id) 
WHERE es.ticket_id=0
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%')

Open in new window

0
srikoteshAuthor Commented:
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
0
PortletPaulfreelancerCommented:
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 )
0
PortletPaulfreelancerCommented:
srikotesh,
You can put most of the conditions into the where clause as Mark has suggested

select t.id,t.name
FROM entry_attributes t  
INNER JOIN entry as e ON t.kb_id=e.id
LEFT OUTER JOIN entry_source es ON e.id=es.kb_id AND es.ticket_id=0
WHERE (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%')


But I can see no other way to "simplify" it, you a searching through 5 string columns for %SSL%.
The only method for simplification I can see is to simplify the requirement.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
MySQL Server

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.