Where in/like

3 posts by 2 authors in: Forums > CMS Builder
Last Post: January 15, 2012   (RSS)

Hi,

I am stuck on something I'm sure I've done before with no troubles...

I have tbl_people, in which has field practice_areas.

The practice_areas field is a multi value checkbox using a mysql query to get values:

SELECT num,title
FROM `<?php echo $TABLE_PREFIX ?>practice_areas`
WHERE parent = ''


Now I want to display related people records on a practice area details page.

If I use this:
'where' => "$thisPage IN (practice_areas)",
($thisPage is the current practice_area detail page)

it only works if the current practice area is first, eg:
$thisPage = 11
people practice_area = '11 23 32' -- will show
people practice_area = '9 11 23' - won't show.

I figure that's because this list needs to be 9,11,23 instead...?

If instead I use
'where' => "practice_areas LIKE '%$parent%'",

it fails on practice_area detail page '1', because it finds 1 in 11, 12, 13 etc instead of just 1.

Am I completely missing something and having Fridayitus? I'm sure I've done this before using IN with no problems -- is there anyway to store the people practice_areas as csv?

Thanks in advance
Rob

Re: [Jason] Where in/like

Hey,

Thanks, the

'where' => "practice_areas LIKE '%\t$parent\t%'",

works perfectly...

Cheers
Rob