insert into addresses(street, city, user_id)
select
'street1','LA', 2
where exists (select * from users where users.id = $$$$$ AND users.storeaddress='true'))
I want to insert address for a user only if the storeaddress value for him is 'true'.
I want to sql to automatically use 2 in place of $$$$$. How to do this in sql?
If I simply do user_id in place of $$$$$ I get
HINT: There is a column named "user_id" in table "addresses", but it cannot be referenced from this part of the query.