Page 1 of 1

lost with select statement

Posted: Sat Oct 08, 2011 5:18 am
by timoteo
Hi everyone. I'm lost with this select statement joined by AND

This statement gives me 3 results echoed in the array at the end : Array ( [0] => 58 [1] => 67 [2] => 73
SELECT DISTINCT recoentryid FROM businessdetails WHERE (street IN('queretaro') OR street LIKE '%queretaro%' OR townborough IN('queretaro') OR townborough LIKE '%queretaro%' OR city IN('queretaro') OR city LIKE '%queretaro%' OR county IN('queretaro') OR county LIKE '%queretaro%' OR state IN('queretaro') OR state LIKE '%queretaro%' OR postcode IN('queretaro') OR postcode LIKE '%queretaro%') Array ( [0] => 58 [1] => 67 [2] => 73 )
This gives me one result:Array ( [0] => 73 )
SELECT DISTINCT recoentryid FROM businessdetails WHERE recoentryid IN('1','73','20','39','40','41','48','50','71','72') Array ( [0] => 73 )
yet when I put them together I get no results (should print 73 (common in both statements).
SELECT DISTINCT recoentryid FROM businessdetails WHERE recoentryid IN('1','73','20','39','40','41','48','50','71','72') AND (street IN('queretaro') OR street LIKE '%queretaro%' OR townborough IN('queretaro') OR townborough LIKE '%queretaro%' OR city IN('queretaro') OR city LIKE '%queretaro%' OR county IN('queretaro') OR county LIKE '%queretaro%' OR state IN('queretaro') OR state LIKE '%queretaro%' OR postcode IN('queretaro') OR postcode LIKE '%queretaro%') Array ( )
Can anyone please shed some light on it. thank you...

Re: lost with select statement

Posted: Mon Oct 10, 2011 5:58 am
by timoteo
resolved - the problem wasn't with the select statement but with my array - I wasn't recording my first result in the array before looping it. thanks for looking