Einzelnen Beitrag anzeigen
  #2  
Alt 16.06.2008, 19:22:21
stb stb ist offline
Anfänger
 
Registriert seit: May 2008
Beiträge: 40
AW: Viele ids mit einem SELECT abfragen

Mit temporären Tabellen kann man das ganz elegant lösen
PHP-Code:
sql"DROP TABLE IF EXISTS temp;";

sql"CREATE TEMPORARY TABLE IF NOT EXISTS temp (id INT(10) );";

$ids = array(1,2,3,4);
$insert " (" join("), ("$ids) . ") ";

sql"INSERT INTO temp (id) VALUES $insert;";


sql"SELECT tabelle.id, tabelle.... 
FROM temp
LEFT JOIN tabelle
ON (temp.id = tabelle.id)

ORDER BY ...;"

__________________
Das schwerste ist das Einfachste:

www.rentstock.de


Geändert von stb (16.06.2008 um 19:25:25 Uhr) Grund: ODER BY => ORDER BY
Mit Zitat antworten