Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Get error when search query run in loop

Posted on 2016-10-10
3
Medium Priority
?
64 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
  • 2
3 Comments
 
LVL 35

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 35

Expert Comment

by:Pawan Kumar
ID: 41837403
Welcome !!
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

In this blog post, we’ll look at how using thread_statistics can cause high memory usage.
In this blog, we’ll look at how improvements to Percona XtraDB Cluster improved IST performance.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses

963 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