Output random blocks from a matrix but without the first I have quotes inside a global matrix which i want to output randomly on the homepage but without the first quote-block. this does not work:

{% set quotes = city.cityBlocks.offset(1) %}
{% set randomQuotes = quotes.limit(1).order('RAND()') %}


the offset in 'quotes' works fine but the first block is still in randomQuotes anyway.
That query would basically tell MySQL to do this:


Shuffle the blocks
Return the second one


Since the shuffling happens before the offset/limit params get applied, they can’t be used to exclude the first block, since the first block will already be put in some random position by that point.

Instead you should get the ID of the first block, and exclude it using that:

{% set firstBlockId = city.cityBlocks.limit(1).ids()|first %}

{% if firstBlockId %}
    {% set randomQuotes = city.cityBlocks.id('not '~firstBlockId).order('RAND()') %}
    ...
{% else %}
    There were no blocks...
{% endif %}