?
Solved

Get error when search query run in loop

Posted on 2016-10-10
3
Medium Priority
?
59 Views
Last Modified: 2016-10-10
when i have serach i have get sql error.

SELECT * FROM employee_info WHERE 1  AND ( ( key_skills LIKE '%PHP%' OR  job_title LIKE '%PHP%' OR  current_designation LIKE '%PHP%' OR  company_name LIKE '%PHP%' OR  objective LIKE '%PHP%' OR  resum_headline LIKE '%PHP%' OR  job_responsibility LIKE '%PHP%' OR  institute LIKE '%PHP%' OR  institute LIKE '%PHP%') OR ( key_skills LIKE '%Java%' OR  job_title LIKE '%Java%' OR  current_designation LIKE '%Java%' OR  company_name LIKE '%Java%' OR  objective LIKE '%Java%' OR  resum_headline LIKE '%Java%' OR  job_responsibility LIKE '%Java%' OR  institute LIKE '%Java%' OR  institute LIKE '%Java%') OR ( key_skills LIKE '%HTML%' OR  job_title LIKE '%HTML%' OR  current_designation LIKE '%HTML%' OR  company_name LIKE '%HTML%' OR  objective LIKE '%HTML%' OR  resum_headline LIKE '%HTML%' OR  job_responsibility LIKE '%HTML%' OR  institute LIKE '%HTML%' OR  institute LIKE '%HTML%') )  AND total_experience < 2 GROUP BY  uid DESC UNION (SELECT * FROM prev_companies WHERE pre_company_name LIKE '%PHP%' OR pre_industry LIKE '%PHP%' OR pre_functional_area LIKE '%PHP%' OR        pre_responsibility LIKE '%PHP%') OR (SELECT * FROM prev_companies WHERE pre_company_name LIKE '%Java%' OR pre_industry LIKE '%Java%' OR pre_functional_area LIKE '%Java%' OR        pre_responsibility LIKE '%Java%') OR (SELECT * FROM prev_companies WHERE pre_company_name LIKE '%HTML%' OR pre_industry LIKE '%HTML%' OR pre_functional_area LIKE '%HTML%' OR        pre_responsibility LIKE '%HTML%')You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'OR (SELECT * FROM prev_companies WHERE pre_company_name LIKE '%Java%' OR pre_ind' at line 1
0
Comment
Question by:Amita Singh
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 30

Accepted Solution

by:
Pawan Kumar earned 2000 total points
ID: 41837368
Pls try this... I think we can add column names and fix it. <<Taking columns from your prev question.>>

SELECT `id` , `uid` ,  `company_name` , `industry` ,  `functional_area` , `current_job_date` , `current_job_date_month` , `job_responsibility`
FROM   employee_info 
WHERE    1 = 1 
AND      (
			 
					  (key_skills LIKE '%PHP%' OR  key_skills LIKE '%Java%'  OR key_skills LIKE '%HTML%') 
			OR       (job_title LIKE '%PHP%'  OR  job_title LIKE '%Java%'  OR  job_title LIKE '%HTML%' )
			OR       (current_designation LIKE '%PHP%'  OR  current_designation LIKE '%Java%'  OR  current_designation LIKE '%HTML%')
			OR       (company_name LIKE '%PHP%' OR  company_name LIKE '%Java%'  OR  company_name LIKE '%HTML%' )
			OR       (objective LIKE '%PHP%'  OR  objective LIKE '%Java%'  OR objective LIKE '%HTML%' )
			OR       (resum_headline LIKE '%PHP%' OR  resum_headline LIKE '%Java%'  OR  resum_headline LIKE '%HTML%' )
			OR       (job_responsibility LIKE '%PHP%'  OR  job_responsibility LIKE '%Java%' OR  job_responsibility LIKE '%HTML%')
			OR       (institute LIKE '%PHP%'  OR  institute LIKE '%Java%'  OR  institute LIKE '%HTML%' )  
		)       
AND     total_experience < 2 
UNION 
SELECT `id` , `uid` ,  `pre_company_name` ,  `pre_industry` ,  `pre_functional_area` ,  `pre_job_date` ,  `pre_job_date_month` ,  `pre_responsibility`  
FROM   prev_companies 
WHERE  
		    (pre_company_name LIKE '%PHP%'  OR pre_company_name LIKE '%Java%'  OR pre_company_name LIKE '%HTML%') 
    OR     (pre_industry LIKE '%PHP%' OR pre_industry LIKE '%Java%' OR pre_industry LIKE '%HTML%') 
    OR     (pre_functional_area LIKE '%PHP%' OR pre_functional_area LIKE '%Java%' OR pre_functional_area LIKE '%HTML%')
    OR     (pre_responsibility LIKE '%PHP%'   OR pre_responsibility LIKE '%Java%' OR pre_responsibility LIKE '%HTML%') 

--

Open in new window

0
 
LVL 2

Author Closing Comment

by:Amita Singh
ID: 41837401
Thank u pawan.
0
 
LVL 30

Expert Comment

by:Pawan Kumar
ID: 41837403
Welcome !!
0

Featured Post

Survive A High-Traffic Event with Percona

Your application or website rely on your database to deliver information about products and services to your customers. You can’t afford to have your database lose performance, lose availability or become unresponsive – even for just a few minutes.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When table data gets too large to manage or queries take too long to execute the solution is often to buy bigger hardware or assign more CPUs and memory resources to the machine to solve the problem. However, the best, cheapest and most effective so…
In this blog post, we’ll look at how using thread_statistics can cause high memory usage.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

718 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question