There are two tables . The values of document.id make a subset to library.book_id . Both columns are not primary keys
Code:
CREATE TABLE document
( id varchar not null,
version varchar,
num_pages number(10),
last_version varchar ,
);
CREATE TABLE library
( book_id varchar not null,
version varchar ,
supplier_id varchar,
arrival_date varchar
);
I need to determine the value for the last_version in the document table. It should be set to 1 if there is no entry in the library table library.book_id=document.id having a higher version then document.version and in other case it should be set to zero if there is an entry in the library table which book_id is equal to document.id having a higher version.
I know to describe it but don't know to write sql command can someone help me?
Thanks