SELECT book.BookTitle, author.Name, author.Surname, book.YearofPublication FROM book LEFT JOIN author ON book.AuthorID = author.AuthorID;
在此輸入圖像描述
這是我目前的表格,我需要建立一個計算欄位來告訴我這本書已經出版了多少年,但我的大腦已經崩潰了。有人可以幫忙嗎?
我嘗試過使用 xaamp 查詢,但沒有看到選項。
P粉2880690452023-09-08 12:43:50
試試這個:
SELECT book.BookTitle, author.Name, author.Surname, book.YearofPublication , YEAR(NOW()) - book.YearofPublication FROM book LEFT JOIN author ON book.AuthorID = author.AuthorID;