I have following two tables:-
postgres=# select * from district;
id | name
----+-----------
1 | Ahmedabad
2 | Barmer
(2 rows)
postgres=# select * from warehouse;
id | name | district_id
----+------+-------------
(0 rows)
I am referring district table from warehouse. Now I want to insert into warehouse. I am using following query
postgres=# insert into warehouse
(name, district_id)
values
('Ghodasar-WH', select id from district where name = 'Ahmedabad');
ERROR: syntax error at or near "select"
LINE 4: ('Ghodasar-WH', select id from district where name = 'Ahmeda...
But it gives me error, as shown above. Why I can't use the result of another select query in the insert query, as I am doing in above query ? I think, what I am doing is a valid scenario. Is there any limitations, that's preventing it from a valid case ?
Thanks in advance.