search

Home  >  Q&A  >  body text

How can I create a calculated field for this table?

SELECT book.BookTitle, author.Name, author.Surname, book.YearofPublication
FROM book
    LEFT JOIN author ON book.AuthorID = author.AuthorID;

Enter image description here

This is my current table, I need to create a calculated field to tell me how many years this book has been published, but my brain is broken. Can anyone help?

I tried using xaamp query but didn't see the option.

P粉425119739P粉425119739553 days ago623

reply all(1)I'll reply

  • P粉288069045

    P粉2880690452023-09-08 12:43:50

    Try this:

    SELECT book.BookTitle, author.Name, author.Surname, book.YearofPublication , YEAR(NOW()) - book.YearofPublication
    FROM book
    LEFT JOIN author ON book.AuthorID = author.AuthorID;
    

    reply
    0
  • Cancelreply