我正在尝试进入此表:
+-------------------------------------------+------------+------------------------+
| Title | Avg Rating | Description Excerpt |
+-------------------------------------------+------------+------------------------+
| The Shortest Book in the World | 10 | A Guide to how Detro...|
| From Deep in the Heart of Texas to IT | 6 | One man's Journey to...|
| From the Shores of Lake Erie to IT | 4 | One man's Journey to...|
| The Science of Literature Searching | NULL | A Book Worth a Look ...|
| Master Wireless Through The Classic Comics| NULL | Infrared man triumph...|
| Master HTML Through The Classic Comics | NULL | Using his Super Web ...|
| Master C++ Through The Classic Comics | NULL | GeekMan triumphs ove...|
+-------------------------------------------+------------+------------------------+
7 rows in set (0.00 sec)
+-------------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------------+--------------+------+-----+---------+-------+
| ISBN | char(13) | NO | PRI | | |
| Title | varchar(70) | NO | | NULL | |
| Description | varchar(100) | YES | | NULL | |
| Category | int(11) | YES | MUL | NULL | |
| Edition | char(30) | YES | | NULL | |
| PublisherID | int(11) | NO | MUL | NULL | |
+-------------+--------------+------+-----+---------+-------+
6 rows in set (0.00 sec)
select b.title as "Title", round(avg(br.rating)) as "Avg Rating",
CONCAT(Description(1, 20, '...')) as "Description Excerpt"
from (book b LEFT JOIN bookreview br on b.ISBN = br.ISBN)
order by upper(b.title);
--------------
select b.title as "Title", round(avg(br.rating)) as "Avg Rating",
CONCAT(Description(1, 20, '...')) as "Description Excerpt"
from (book b LEFT JOIN bookreview br on b.ISBN = br.ISBN)
order by upper(b.title)
--------------
ERROR 1305(42000):功能书。描述不存在
我对这个错误感到困惑,但是当我为我的书桌运行desc时,带有描述的书桌就会显示出来。我需要帮助解决问题。
答案 0 :(得分:1)
我认为你想要一个带有concat的SUBSTR函数,所以改变
CONCAT(Description(1, 20, '...'))
要
CONCAT(substr(Description ,1, 20), '...')