m8t Posted September 29, 2009 Report Share Posted September 29, 2009 Tātad, pašlaik mans kods ir aptuveni šāds: $query9 = "SELECT absx, absy FROM {$tblprefix}users WHERE absx='{$absx}' AND absy='{$absy}'"; $run9 = mysql_query($query9); while($row9 = mysql_fetch_array($run9)) { $p2_absx = $row9['absx']; $p2_absy = $row9['absy']; $query = "SELECT absx, absy FROM {$tblprefix}users WHERE absx='{$p2_absx}'"; $run = mysql_query($query); while($row = mysql_fetch_array($run)) { $p23_absx = $row['absx']; } } ^Tikai piemērs, pašlaik neko tādu nekur neizmantoju Tātad, kā lai viņu pārveido vienā selectā? Es zinu, ka var kautkā, bet nemāku, vēlētos redzēt piemēru, lai varētu iemācīties, kā darīt šo lietu. ps.- bija grūti paskaidrot šo, ceru ka sapratāt domu. Quote Link to comment Share on other sites More sharing options...
waplet Posted September 29, 2009 Report Share Posted September 29, 2009 UNION ? Quote Link to comment Share on other sites More sharing options...
marrtins Posted September 29, 2009 Report Share Posted September 29, 2009 Ja vajag rezultātus gan no pirmā selekta gan no otrā, tad: SELECT absx, absy FROM {$tblprefix}users WHERE absx='{$absx}' AND absy='{$absy}' UNION SELECT absx, absy FROM {$tblprefix}users WHERE absx IN ( SELECT absx FROM {$tblprefix}users WHERE absx='{$absx}' AND absy='{$absy}' ); Ja vajag rezultātu tikai no otrā selekta, tad: SELECT absx, absy FROM {$tblprefix}users WHERE absx IN ( SELECT absx FROM {$tblprefix}users WHERE absx='{$absx}' AND absy='{$absy}' ); P.S. Piemērs aptuvens - neesmu testējis Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.