lost with select statement

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
timoteo
Forum Contributor
Posts: 125
Joined: Sat Jan 08, 2011 6:46 am

lost with select statement

Post 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...
timoteo
Forum Contributor
Posts: 125
Joined: Sat Jan 08, 2011 6:46 am

Re: lost with select statement

Post 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
Post Reply