[thelist] MySQL sub-select with PHP [was: sql cross table exclusion??]

rudy r937 at interlog.com
Fri Aug 30 19:51:01 CDT 2002


> what other options do I have for implementing
> this sort of iterative sub-select?

hi mike

hey, thanks for the kind words

here are some helpful guidelines:

rule number 1 -- never do in code what the database can do in sql

rule number 2 -- go read rule number 1 again!!


so, your scenario of running a query and saving the results in php would
seem to violate that guideline

why not save the results in a temp table in the database?

then you can use that table to join with other tables for iterative
searches

trust me, the code you have to write in php becomes a lot simpler

complex code is *much* harder to figure out than simple code

especially when you are juggling arrays, structures, session variables, et
cetera

oh, sure, it's easy to *write* -- that's not the hard part

the hard part comes six months down the road when you've forgotten all your
nifty neato code, and have to make a change to it

rudy




More information about the thelist mailing list