Solved

Get error when search query run in loop

Posted on 2016-10-10
3
37 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 17

Accepted Solution

by:
Pawan Kumar Khowal 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 17

Expert Comment

by:Pawan Kumar Khowal
ID: 41837403
Welcome !!
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
.htaccess file settings 4 35
Generating a set of random unique numbers 6 19
PHP loop not working 4 32
Instering to MySQL table 5 19
Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to dynamically set the form action using jQuery.

705 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now