Reply to Re: Constructing a search query

Your name:

Reply:


Posted by larry on 12/17/06 06:08

kenoli wrote:
> I am doing a compound lookup by deriving person_id values for a query
> from various tables by selecting arrays of person_id values that meet
> my criteria from those tables. I am ending up with a query whose logic
> would be something like:
>
> SELECT * FROM tbl_person WHERE first_name = "John" AND (person_id = '2'
> OR person_id = '4' OR person_id = '6' OR person_id = '10') AND
> (person_id = '1' OR person_id = '4' OR person_id = '10' OR person_id =
> '20') AND (person_id = '4' OR person_id = '7' OR person_id = '6' OR
> person_id = '10');
>
> I have the id values from the lookup tables in separate arrays. I'm
> thinking that the equivalent to the above query would be an array made
> up only of values that show up in all three arrays. I could then
> create a simpler query like:
>
would
array_intersect($array1,$array2,$array3)
work?

Look up array_intersect on php.net to get more insight on variatons,
refinements
http://us2.php.net/manual/en/function.array-intersect.php

FYI - Programming PHP (O'Reiley) does a great job of covering array
functions as well as most other PHP functions.

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация