mors Posted May 9, 2004 Report Share Posted May 9, 2004 ir tabula ar 2 laukiem - text varchar(255) un date (datetime), vajadzetu ar mysql queriju izdzest visus ierakstus, iznemot jaunakos 100 (skatoties pec date). meginaju ar mysql_query("DELETE FROM table ORDER BY date DESC LIMIT 100,1000") or die (mysql_error()); bet dabuju sadu erroru: You have an error in your SQL syntax near 'ORDER BY date DESC LIMIT 100,1000' at line 1 Kas tur ir nepareizi un/vai ka citadak realizet to? Link to comment Share on other sites More sharing options...
Aleksejs Posted May 9, 2004 Report Share Posted May 9, 2004 Varbūt ar diviem kverijiem to vari realizēt: SELECT date FROM table LIMIT 100, 1 ielasi šo date mainīgajā $datums(laikam var izdarīt uzreiz ar mysql, bet neesmu nekad to darījis, tādēļ neieteikšu) DELETE * FROM table WHERE date < $datums Protams, tas tikai tad, ja, piemēram, visi 110 ieraksti nav ar vienādu datumu. Link to comment Share on other sites More sharing options...
bubu Posted May 10, 2004 Report Share Posted May 10, 2004 lasam manuālī kāpēc nevar lietot LIMIT pie DELETE: ORDER BY and using multiple tables in the DELETE statement is supported in MySQL 4.0. Link to comment Share on other sites More sharing options...
bubu Posted May 10, 2004 Report Share Posted May 10, 2004 Varbūt ar diviem kverijiem to vari realizēt:SELECT date FROM table LIMIT 100, 1 ielasi šo date mainīgajā $datums(laikam var izdarīt uzreiz ar mysql, bet neesmu nekad to darījis, tādēļ neieteikšu) DELETE * FROM table WHERE date < $datums Protams, tas tikai tad, ja, piemēram, visi 110 ieraksti nav ar vienādu datumu. selekts nekorekts! netiek kārtots pēc datumiem :) Link to comment Share on other sites More sharing options...
Aleksejs Posted May 10, 2004 Report Share Posted May 10, 2004 Nu tas tikai idejiskā līmeni bija :P Link to comment Share on other sites More sharing options...
Recommended Posts