loops - JOIN SQL Query for Improved Performance -
i having performance issues , want understand joining of sql queries achieves, have read example , consider myself avid coder 1 baffles me, point did below achieve goal....
you'll see below, first auxkey staux000 webshow = 'y'
these results in array implode commas use in next query! - bad know , or it...
i want end of with, in end stock table auxkey set 'y' in staux000
make sense?
$webshow = "select auxkey staux000 webshow = 'y' "; $wsres = odbc_exec($connectforwebshow, $webshow); while( $wsrow = odbc_fetch_array($wsres) ) { $_session[showontheweb][] = $wsrow[auxkey]; } $showondaweb = $_session[showontheweb]; $imploded_arr = implode("', '000", $showondaweb); $cfwsq = db_connect(); $wstquery = "select name, number stock "; $wstquery .= "where stock.location = 'lane' , upper(stock.name) upper('%') , number in ('000"; $wstquery .= "$imploded_arr"; $wstquery .= "') "; $wbstres = odbc_exec($cfwsq, $wstquery); while( $wbstrow = odbc_fetch_array($wbstres) ) { $number = $wbstrow[number]; $_session[allstock][name][] = ($wbstrow[name]); $_session[allstock][number][] = ($wbstrow[number]); }
why don't try join sql code sql optimize it.
something like:
select name, number stock stock.location = 'lane' , upper(stock.name) upper('%') , exists ( select auxkey staux000 webshow = 'y' , stock.number = staux000.auxkey )
Comments
Post a Comment