CREATE TABLE foo ( id BIGSERIAL NOT NULL UNIQUE PRIMARY KEY, type VARCHAR(60) NOT NULL UNIQUE );
CREATE TABLE bar (
id BIGSERIAL NOT NULL UNIQUE PRIMARY KEY,
description VARCHAR(40) NOT NULL UNIQUE,
foo_id BIGINT NOT NULL REFERENCES foo ON DELETE RESTRICT
);
Say the first table foo is populated like this:
INSERT INTO foo (type) VALUES
( 'red' ),
( 'green' ),
( 'blue' );
can I have the query which can work in java actually the below query is working while inserting in php my admin but in java it is not working ... please help me to write this query in java INSERT INTO bar (description, foo_id) VALUES ( 'testing', (SELECT id from foo WHERE type='blue') ), ( 'another row', (SELECT id from foo WHERE type='red' ) );
Aucun commentaire:
Enregistrer un commentaire