SQLite Forum

INSERT with RETURNING causes duplicate rows
Login
Using your SQL with the v3.35.5 SQLite shell, I get just one row of results, just as we should expect.

I do not know what you, your PHP code, or the PHP driver are doing to produce results which puzzle you, and I am not willing to engage in a guessing session to find out. I doubt that anybody else will be willing either. In other words, I cannot see what you are doing wrong and expect nobody else can.

To get your problem resolved here, it would be better to provide a sequence of SQL statements which replicate your problem in the CLI shell. There is a good chance that, in the course of doing that, you will discover the problem. If not, you will give others here a chance to solve it. Until then, you should expect no replies that resolve it.

Perhaps unrelatedly: I would change the first table column from<code>
  profile_id INTEGER NOT NULL PRIMARY KEY autoincrement,
</code>to<code>
  profile_id INTEGER PRIMARY KEY,
</code>unless you truly need to avoid ever reusing id values after a row using one of them has been deleted.