<div>‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐<br></div><div> On Sunday, May 19, 2019 4:44 PM, John Fawcett via dovecot <dovecot@dovecot.org> wrote:<br></div><div> <br></div><blockquote class="protonmail_quote" type="cite"><div class="moz-cite-prefix">I don't have PostgresSql, would you be able to verify if this syntax would work:

INSERT INTO last_logins (last_login,username,domain) VALUES (1558273000,'<a href="mailto:user@domain.tld">user@domain.tld</a>','domain.tld') <span>ON </span>CONFLICT<span> </span>(<span>username</span>) <span>UPDATE SET last_login=</span>1558273000,domain='<a href="mailto:user@domain.tld">user@domain.tld</a>'

It's important to check that this updates only the single row for that user and it puts the right data in that row. If it doesn't work can you give the correct syntax?<br></div></blockquote><div><br></div><div>So you nearly yes ;-) The only parameter missing was "DO" keyword before the "UPDATE". So the correct query would be:<br></div><div><br></div><div>INSERT INTO last_logins (last_login,username,domain) VALUES (1558273000,'<a href="mailto:user@domain.tld">user@domain.tld</a>','domain.tld') ON CONFLICT (username) DO UPDATE SET last_login=1558273000,domain='domain.tld';<br></div><div><br></div><div>I also adapted the domain='domain.tld' at the end of the query, you had domain='<a href="mailto:user@domain.tld">user@domain.tld</a>' but this is just a "content" detail which does not matter.<br></div><div><br></div><div>Hope that helps. Let me know if I can do any further testing.<br></div><div><br></div>