2
SELECT BookId, Duedate, (SELECT Title FROM Book_Information WHERE BookId = BookId)
FROM Transaction_Information WHERE DueDate <= CURDATE() AND ReturnedDate IS NULL

The book id is the foreign key in the transaction_information. I want to add the Title field from the book information table to the transaction information table

progammer101
  • 47
  • 1
  • 8

2 Answers2

0

Since Transaction_Information.BookId is the foreign key which refers to the corresponding row in Book_Information table then a simple INNER JOIN would do the job.

Here's the query:

SELECT
TF.BookId,
TF.Duedate,
BF.Title
FROM Transaction_Information TF
INNER JOIN Book_Information BF
ON TF.BookId = BF.BookId
WHERE TF.DueDate <= CURDATE() AND TF.ReturnedDate IS NULL;
1000111
  • 13,169
  • 2
  • 28
  • 37
0

Try this query :

select * from Transaction_Information tf,Book_Information bf where tf.BookId = bf.BookID and tf.DueDate <= CURDATE() and tf.ReturneDate is null ;
Purvi Barot
  • 241
  • 2
  • 9