php - MySQL UNION returning no results whatsoever -
i've been tearing hair out @ inability understand seems simple issue. i'm making small business contacts system enable our company store contact details of other business/companies business contacts (can freelancers or linked added companies. i'm trying have 1 search form enable me search either name of contact or name of business in both arabic , english. what doing wrong?
update: union query works if remove arabic search portions each query section (i.e. removed "or contact_name_arabic '%".$querystring."%'" "or company_name_arabic '%".$querystring."%'")
this becoming more complicated :/
table 1: companies
id | company_name | company_name_arabic ----------------------------------------------- 1 | red arrow | السهم الأحمر 2 | white tower | البرج الأبيض 3 | mobilex | موبيليكس
table 2: contacts
id | company_id | contact_name | contact_name_arabic ---------------------------------------------------------------- 1 | 1 | saeed adam | سعيد آدم 2 | 1 | andrew white | أندرو وايت 3 | 2 | steve rogers | ستيف روجرز
here mysql statement:
$querystring = "(select contact_name, contact_name_arabic contacts contact_name '%".$querystring."%' or contact_name_arabic '%".$querystring."%') union (select company_name, company_name_arabic companies company_name '%".$querystring."%' or company_name_arabic '%".$querystring."%')";
thanks!
try query in mysql query builder
(select contact_name, contact_name_arabic contacts contact_name '%e%' or contact_name_arabic '%e%') union (select company_name, company_name_arabic companies company_name '%e%' or company_name_arabic '%e%')
if working check value comes in variable $querystring.
and not need check field company_name_arabic
(select contact_name, contact_name_arabic contacts contact_name '%e%') union (select company_name, company_name_arabic companies company_name '%e%' )
Comments
Post a Comment