Solved

Get error when search query run in loop

Posted on 2016-10-10
3
57 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 29

Accepted Solution

by:
Pawan Kumar earned 500 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 29

Expert Comment

by:Pawan Kumar
ID: 41837403
Welcome !!
0

Featured Post

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
In this series, we will discuss common questions received as a database Solutions Engineer at Percona. In this role, we speak with a wide array of MySQL and MongoDB users responsible for both extremely large and complex environments to smaller singl…
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.

615 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