I have a quite hard time with the following queries. I have the following tables:
however, when the admin promote a book, the "available" row will be false until the remove_time will activate the automatic function to remove the promotion.
Book Image table Contains all the images links and the book id assigned of individual books. Here is possible by requirement not to have any book image assigned.
Promotion table This table contain a start date (default), end date, new price, and book ID. The main thing is that when the server reads the end date, the deletion of the product from the promotion table will automatically be removed. All the books that are found in the promoted table have the "available" row value false.
I need two queries, or JS functions to select all the books promoted and unpromoted while taking in consideration the new_price from the promoted table (if the bookID is inside the table) and also the book images from the table.
I tried this, but when the book contains more images, I get duplicate books for each images,....
select * from magicpapers.books
right join magicpapers.bookimages
ON books.bookID = bookimages.bookID
Thanks, Daniel