How to get value from subquery in mysql? I have this two tables:
Article:
- id:(int) primary key, autoincrement, not null,
- title:(varchar) not null,
- price:(decimal) not null,
- cart_id(int) not null, //foreign key 
- book_id(int) not null, //foreign key 
- image_id(int) not null, //foreign key 


Image:
- id:(int) primary key, autoincrement, not null,
- image:(Blob) not null

and
 Book:
- id:(int) primary key, autoincrement, not null,
- title:(varchar) not null,
- price:(decimal) not null,
- image_id(int) not null, //foreign key 

I want when inserting into Article to insert also right image_id, here is query where i try to that:
insert into article(title,price,cart_id,book_id) 
values('Book1',20.00,387,
(select b.id from books b join article a where b.title =  a.title limit 1))

When i run query like this(without image) it works fine, but i can't figure out query with image_id. So i thought maybe if i can get value from subquery select b.id from books b join article a where b.title =  a.title i can just to thisselect id from image where id= result from that query(i have foreign key book_image in book table btw). Am i totally missing point if not, how to solve this?
But as i said you don't need in article
title and image, as they are already existent in books and you can always join the books table
But you would do this so
INSERT INTO article(title,price,cart_id,book_id,image_id) 
VALUES ('Book1',20.00,387,
(select b.id from books b  where b.title =  'Book1' limit 1),
(select b.image_id from books b where b.title =  'Book1' limit 1))