title: Removing element from array within object JSONB
body: <p>I am attempting to remove an element from my database. The element I want to remove is within a JSON object called playerContainer which contains an array named players. This all sits within a table called site_content. I am trying to remove the object based on it's ID, however I get this error.</p>
  
  <blockquote>
    <p>DELETE elem
                        from site_content,
                        lateral jsonb_array_elements(content->'playersContainer'->'players') elem
                        where elem @> '{"id":"22"}'<br>
               because: ERROR: syntax error at or near "elem"   Position: 27</p>
  </blockquote>
  
  <p>Below is my query, can anyone see where I am going wrong?</p>
  
  <pre><code>DELETE elem 
  from site_content, 
  lateral jsonb_array_elements(content-&gt;'playersContainer'-&gt;'players') elem 
  where elem @&gt; '{"id":"1"}' 
  </code></pre>
  
  <p>Here is the sample JSON</p>
  
  <pre><code>"playersContainer": {
          "players": [
              {
                  "id": "1",
                  "name": "Nick",
                  "teamName": "Shire Soldiers",
                  "ratings": [
                      1,
                      5,
                      6,
                      9
                  ],
                  "assists": 17,
                  "manOfTheMatches": 20,
                  "cleanSheets": 1,
                  "data": [
                      3,
                      2,
                      3,
                      5,
                      6
                  ],
                  "totalGoals": 19
  
              },
  }
  </code></pre>