[mysql] FIFO queue?*

Pagina: 1
Acties:

  • Major Asshole
  • Registratie: Mei 2000
  • Laatst online: 24-06-2024

Major Asshole

Are there any more Asholes?

Topicstarter
Ik probeer een simpele fifo queue in mysql te proggen. Tot nu toe is het toevoegen en selecteren van records geen probleem, maar bij deleten gaat het fout:

"select * from queue order by id limit 1;"

hierop krijg ik netjes de eerste (laagste id) uit de queue maar

delete from queue order by id limit 1;

geeft mij een "ERROR 1064 at line 1: You have an error in your SQL syntax near 'order by id limit 1' at line 1". Als ik de handleiding lees zou het toch moeten kunnen... enig idee?

  • Grum
  • Registratie: Juni 2001
  • Niet online
vind dat dit stukje text van http://www.mysql.com/doc/D/E/DELETE.html niet uitsluit dat het ALLEEN in 4.X werkt
[snip]
ORDER BY and using multiple tables in the DELETE is supported in MySQL 4.0.

If an ORDER BY clause is used, the rows will be deleted in that order. This is really only useful in conjunction with LIMIT. For example:
[/snip]

  • Major Asshole
  • Registratie: Mei 2000
  • Laatst online: 24-06-2024

Major Asshole

Are there any more Asholes?

Topicstarter
Op woensdag 27 februari 2002 17:26 schreef Grum_ het volgende:
vind dat dit stukje text van http://www.mysql.com/doc/D/E/DELETE.html niet uitsluit dat het ALLEEN in 4.X werkt
Tsja... 4.0.1 alpha dan maar eens proberen.

  • _Stryker_
  • Registratie: Januari 2001
  • Laatst online: 27-04-2025
probeer eens

delete from queue where id = select id from queue order by id limit 1;

  • Grum
  • Registratie: Juni 2001
  • Niet online
* Grum besteld 1 kilo clue

>:) ... lees de topic voor je replied plz ... >:)

het is MYSQL, dat is aardsvijand nummer 1 van subqueries :)