我正试着走到这张桌子上:
+-------------------------------------------+------------+------------------------+
| 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)
--------------错误1305 (42000):函数book.Description不存在
我对这个错误感到困惑,但是当我对我的图书表运行desc时,带有描述的图书表马上就会显示出来。我需要帮助来弄清楚这个问题。
发布于 2013-12-04 12:46:22
我认为您需要一个带有连接的SUBSTR函数,因此,请更改
CONCAT(Description(1, 20, '...'))至
CONCAT(substr(Description ,1, 20), '...')https://stackoverflow.com/questions/20367009
复制相似问题