---
title: "orderBy = RAND() TYPO3 8.7"
url: "https://www.typo3.net/d/125960-orderby-rand-typo3-87"
source: "typo3.net"
tags: ["TYPO3","TypoScript","Datenbank","Frage","TYPO3 8"]
created: "2017-05-05"
last_reply: "2017-10-13"
replies: 3
solved: false
page: 1
pages: 1
lang: "de"
---

# orderBy = RAND() TYPO3 8.7

TYPO3 › TypoScript · 3 Antworten · gestartet 2017-05-05

## Eröffnungsbeitrag

**thowe** · 2017-05-05 · [Beitrag #1](https://www.typo3.net/d/125960-orderby-rand-typo3-87/1)

Hallo liebe Foristi

möchte von einem bestimmten SysFolder (id=23) zufälligen INhalt aus der Spalte normal (colPos=0) ausgeben.

Folgendes TS-Snippet

```typoscript
lib.randomRatings = COA_INT
lib.randomRatings {
  10 = CONTENT
  10 {
    table = tt_content
    select {
      pidInList = 23
      where = colPos = 0
      orderBy = RAND()
      max = 2
      languageField = sys_language_uid
    }
    renderObj < tt_content
    renderObj.stdWrap.wrap = <div class="randomRatings">|</div>
    renderObj.stdWrap.required = 1
  }
}
```

führt zu folgedner Fehlermeldung:

Ooops an Error occured (...)
(...) unknown column RAND() (...)

Hat jemand eine Idee, wie man einen zufälligen Inhalt aus der Spalte tt_content generieren kann?

## Antworten

### [#2](https://www.typo3.net/d/125960-orderby-rand-typo3-87/2) · thowe · 2017-05-26

Hallo,

hat wirklich niemand eine Lösung, oder zumindest einen Ansatz, eine Anregung, eine Idee...?

### [#3](https://www.typo3.net/d/125960-orderby-rand-typo3-87/3) · seebold · 2017-05-30

Ich stehe vor dem selben Problem und würde mich freuen, wenn jemand eine Lösung weiß.

Liebe Grüße
Martin

### [#4](https://www.typo3.net/d/125960-orderby-rand-typo3-87/4) · stosef · 2017-10-13

Hi,
meine Lösung:

```typoscript
block.teaser = COA_INT
block.teaser {
    10 = CONTENT
    10 {
        table = tt_content
        select {

            selectFields = *, rand() as virt_rnd

            # UID of the page with the content elements
            pidInList = 1
            where = colPos=1

            # amount of content elements to find
            max = 4

            # randomize
            orderBy = virt_rnd

            # constrain by language
            languageField = sys_language_uid
        }
    }
}
```

---

Quelle: „orderBy = RAND() TYPO3 8.7“, typo3.net, https://www.typo3.net/d/125960-orderby-rand-typo3-87
Beiträge von Mitgliedern des Forums. Bitte mit Link auf die Diskussion zitieren.
