Solved

Get error when search query run in loop

Posted on 2016-10-10
3
54 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 28

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 28

Expert Comment

by:Pawan Kumar
ID: 41837403
Welcome !!
0

Featured Post

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

Suggested Solutions

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
This article discusses how to create an extensible mechanism for linked drop downs.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to dynamically set the form action using jQuery.

752 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