Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>An <a href="http://www.postgresql.org/docs/8.4/static/sql-insert.html"><code>INSERT</code> statement</a> is only for creating completely new records, not for populating data into existing ones. What you need is an <a href="http://www.postgresql.org/docs/8.4/static/sql-update.html"><code>UPDATE</code> statement</a>, which updates an existing record:</p> <pre><code>UPDATE bike SET full_day = 10 WHERE bike_type = 'mens_hybrid'; </code></pre> <hr> <p>(Note: below is an earlier version of this answer, from before it was clear to me what the original poster was trying to do. I'm leaving it here because multiple people who originally answered this question did not seem to notice the problem with writing <code>INSERT ... VALUES (...) WHERE</code>, which makes me think that this explanation might be useful to some people coming across this question.)</p> <hr> <p>That statement doesn't make sense. An <code>INSERT</code> can't take a <code>WHERE</code> clause, because <code>WHERE</code> refers to existing records, and an <code>INSERT</code> creates new ones.</p> <p>(To forestall potential confusion: there exists such a thing as <code>INSERT INTO ... SELECT ...</code>, where the records to insert are determined by a <code>SELECT</code> query rather than by a <code>VALUES</code> expression, and in that case the <code>SELECT</code> query can, of course, have a <code>WHERE</code> clause. But in no case does the <code>WHERE</code> clause belong to the <code>INSERT</code> statement directly.)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload