<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Inserts and Updates on BareSQL.com</title>
    <link>https://baresql.com/tags/inserts-and-updates/</link>
    <description>Recent content in Inserts and Updates on BareSQL.com</description>
    <generator>Hugo</generator>
    <language>en-us</language>
    <lastBuildDate>Mon, 26 Oct 2026 00:00:00 +0000</lastBuildDate>
    <atom:link href="https://baresql.com/tags/inserts-and-updates/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>INSERT IGNORE Becomes INSERT OR IGNORE on SQLite and ON CONFLICT DO NOTHING on PostgreSQL</title>
      <link>https://baresql.com/insert-ignore-becomes-insert-or-ignore-on-sqlite-and-on-conflict-do-nothing-on-postgresql/</link>
      <pubDate>Mon, 26 Oct 2026 00:00:00 +0000</pubDate>
      <guid>https://baresql.com/insert-ignore-becomes-insert-or-ignore-on-sqlite-and-on-conflict-do-nothing-on-postgresql/</guid>
      <description>&lt;p&gt;Loading a file of events that may hold rows you already have calls for an insert that skips duplicates. MySQL and MariaDB spell it &lt;code&gt;INSERT IGNORE&lt;/code&gt; and SQLite &lt;code&gt;INSERT OR IGNORE&lt;/code&gt;, while PostgreSQL and SQLite take &lt;code&gt;ON CONFLICT DO NOTHING&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Each form skips rows that would break a unique key, and each fails on the engines that use another one. INSERT IGNORE also hides other errors on MySQL and MariaDB, such as values that do not fit the column.&lt;/p&gt;</description>
    </item>
    <item>
      <title>MySQL Refuses an UPDATE Whose Subquery Reads the Same Table</title>
      <link>https://baresql.com/mysql-refuses-an-update-whose-subquery-reads-the-same-table/</link>
      <pubDate>Mon, 26 Oct 2026 00:00:00 +0000</pubDate>
      <guid>https://baresql.com/mysql-refuses-an-update-whose-subquery-reads-the-same-table/</guid>
      <description>&lt;p&gt;Marking rows with &lt;code&gt;UPDATE t SET flag = 1 WHERE id IN (SELECT id FROM t WHERE ...)&lt;/code&gt; works on SQLite, PostgreSQL and MariaDB. MySQL refuses an UPDATE or DELETE whose subquery reads the table being changed.&lt;/p&gt;&#xA;&lt;p&gt;MySQL says you can’t specify target table &#39;t&#39; for update in FROM clause. MariaDB lifted the limit in version 10.3.2. A subquery used as a table works on MySQL too, because MySQL then computes its rows before it changes anything.&lt;/p&gt;</description>
    </item>
    <item>
      <title>MySQL Refuses INSERT RETURNING While PostgreSQL and SQLite Accept It</title>
      <link>https://baresql.com/mysql-refuses-insert-returning-while-postgresql-and-sqlite-accept-it/</link>
      <pubDate>Mon, 26 Oct 2026 00:00:00 +0000</pubDate>
      <guid>https://baresql.com/mysql-refuses-insert-returning-while-postgresql-and-sqlite-accept-it/</guid>
      <description>&lt;p&gt;&lt;code&gt;INSERT ... RETURNING id&lt;/code&gt; hands back the new row’s id in the same round trip on SQLite, PostgreSQL and MariaDB. MySQL has no RETURNING and refuses the statement.&lt;/p&gt;&#xA;&lt;p&gt;SQLite added RETURNING in version 3.35, and MariaDB in 10.5 for INSERT and DELETE (MariaDB refuses it on UPDATE). Each engine also has its own function for the last generated id: LAST_INSERT_ID() on MySQL and MariaDB, last_insert_rowid() on SQLite and lastval() on PostgreSQL.&lt;/p&gt;</description>
    </item>
    <item>
      <title>SQLite Has No TRUNCATE Statement</title>
      <link>https://baresql.com/sqlite-has-no-truncate-statement/</link>
      <pubDate>Mon, 26 Oct 2026 00:00:00 +0000</pubDate>
      <guid>https://baresql.com/sqlite-has-no-truncate-statement/</guid>
      <description>&lt;p&gt;Test setups often empty their tables with &lt;code&gt;TRUNCATE TABLE&lt;/code&gt; between runs. PostgreSQL, MySQL and MariaDB have it, and SQLite refuses it.&lt;/p&gt;&#xA;&lt;p&gt;SQLite empties a table quickly with a DELETE FROM t that has no WHERE clause. On MySQL and MariaDB, TRUNCATE also resets the AUTO_INCREMENT counter, which DELETE leaves alone.&lt;/p&gt;&#xA;&lt;p&gt;&lt;img src=&#34;https://baresql.com/images/rule-truncate.png&#34; alt=&#34;TRUNCATE TABLE t; SELECT COUNT(*) FROM t, run on four engines: SQLite 3.45.1 error: near &amp;quot;TRUNCATE&amp;quot;: syntax error; PostgreSQL 16.15 0; MySQL 8.0.46 0; MariaDB 10.11.14 0.&#34;&gt;&lt;/p&gt;</description>
    </item>
    <item>
      <title>UPDATE With a Join Needs Different Syntax on MySQL and PostgreSQL</title>
      <link>https://baresql.com/update-with-a-join-needs-different-syntax-on-mysql-and-postgresql/</link>
      <pubDate>Mon, 26 Oct 2026 00:00:00 +0000</pubDate>
      <guid>https://baresql.com/update-with-a-join-needs-different-syntax-on-mysql-and-postgresql/</guid>
      <description>&lt;p&gt;Copying prices from a staging table with a join takes &lt;code&gt;UPDATE ... FROM&lt;/code&gt; on SQLite and PostgreSQL and &lt;code&gt;UPDATE ... JOIN&lt;/code&gt; on MySQL and MariaDB, and neither runs on all four.&lt;/p&gt;&#xA;&lt;p&gt;The engines use different syntax for changing rows based on another table. DELETE differs the same way: DELETE ... USING on PostgreSQL, DELETE t FROM t JOIN ... on MySQL and MariaDB.&lt;/p&gt;&#xA;&lt;p&gt;&lt;img src=&#34;https://baresql.com/images/rule-update-join.png&#34; alt=&#34;UPDATE t SET x = u.x FROM u WHERE u.id = t.id; SELECT x FROM t ORDER BY id, run on four engines: SQLite 3.45.1 7; 0; PostgreSQL 16.15 7; 0; MySQL 8.0.46 error: You have an error in your SQL syntax ... near &#39;FROM u WHERE u.id = t.id&#39; at line 1; MariaDB 10.11.14 error: You have an error in your SQL syntax ... near &#39;FROM u WHERE u.id = t.id&#39; at line 1.&#34;&gt;&lt;/p&gt;</description>
    </item>
    <item>
      <title>Upsert Needs ON CONFLICT on PostgreSQL and ON DUPLICATE KEY UPDATE on MySQL</title>
      <link>https://baresql.com/upsert-needs-on-conflict-on-postgresql-and-on-duplicate-key-update-on-mysql/</link>
      <pubDate>Mon, 26 Oct 2026 00:00:00 +0000</pubDate>
      <guid>https://baresql.com/upsert-needs-on-conflict-on-postgresql-and-on-duplicate-key-update-on-mysql/</guid>
      <description>&lt;p&gt;Saving a setting that may or may not exist yet takes one statement on every engine, though not the same one on all four. SQLite and PostgreSQL use &lt;code&gt;ON CONFLICT ... DO UPDATE&lt;/code&gt;, MySQL and MariaDB &lt;code&gt;ON DUPLICATE KEY UPDATE&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;REPLACE INTO works on SQLite, MySQL and MariaDB, but it deletes the old row and inserts a new one, which fires delete triggers and resets the columns the statement leaves out. Of these four engines, MERGE exists on PostgreSQL 15 and later only.&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
