php - Query column for multiple values -
i have table looks 1 below, , doing search query multiple fields refine search job. @ moment able enter multiple fields, however, search results query entire database, not 1 specific id.
table:
contentid meta_key meta_value 1 1 vacancytype hospitality 2 1 vacancyrole chef 3 1 vacancydate 2014-01-01 4 2 vacancytype adin 5 2 vacancyarea st albans 6 2 vacancydate 2014-01-01
code:
$getjobs1 = "select distinct * cms_contentextra, cms_content cms_contentextra.meta_value in ('$type','$key') , cms_content.contentid = cms_contentextra.contentid group cms_content.contentid"; $getjobs2 = mysql_query($getjobs1) or die("didn't query"); while ($getjobs3 = mysql_fetch_array($getjobs2)) { echo ' - ' . $getjobs3[meta_value] . ' - ' . ' - ' . $getjobs3[contentid]; }
this return:
- st albans - - 8435 - st albans - - 8436 - hospitality & catering - - 8437 - st albans - - 8440 - hospitality & catering - - 8444 - hospitality & catering - - 8450 - hospitality & catering - - 8451 - st albans - - 8453
however, want show results have both area , type, , disregard others. @ moment seems displaying type , displaying area separately, unable show type in specific area.
i using 2 tables compare contentid more data stored in different table.
the in
operand use or
operation.
try use like
such as:
where cms_contentextra.meta_value "%$type%$key%" or cms_contentextra.meta_value "%$key%$type%"
Comments
Post a Comment