sql >> Database teknologi >  >> RDS >> Mysql

Erstatning for MySQL's variabler i PostgreSQL?

Brug VALUES() i en SELECT, der burde virke:

INSERT INTO employees (
    company_id,
    name,
    position,
    created_by,
    last_modified_by
)
SELECT
    (SELECT id FROM companies WHERE name = 'Acme Fellowship'),
    name,
    position,
    (SELECT id FROM users WHERE login = 'admin'),
    (SELECT id FROM users WHERE login = 'admin')
FROM
    (VALUES -- all your new content here
        ('Frodo Baggins',  'Ring bearer'), 
        ('Samwise Gamgee', 'Rope bearer'), 
        ('Peregrin Took',  'Ent rider')
    ) content(name, position); -- use some aliases to make it readable


  1. UTF-8 problemer med PHP/MySQL

  2. Dvale navnestrategi, ændring af tabelnavne

  3. Hvad kan få en Oracle ROWID til at ændre sig?

  4. CURRENT_TIMESTAMP i millisekunder i h2