SQL> select 'Item '|| Item_id|| 'is described as a'|| item_desc||'.' "Item Description Sentence"
2 from plsql101_old_item;Item Description Sentence
--------------------------------------------------------------------
Item LA-101 is described as aCan,Small .
Item LA-102 is described as aCan,Large .
Item LA-103 is described as aBottle,Small .
Item LA-104 is described as aBottle,Large .
Item LA-101 is described as aBox,Small .
Item NY-102 is described as aBox,Large .
Item NY-103 is described as aShipping Carton,small .
Item NY-104 is described as aShipping Cartom,Large .已选择8行。我看书,书上有这么一个例子,我看不懂。
请问这个SQL语句是什么意思呀,我知道“||”是布尔表达式,原来表plsql101_old_item应该只用“ITEM_DESC”、“ CATEGORY”、“ITEM_SIZE”这三列呀,其他的列我不知道怎么通过这个语句添加上去的?
比如要连接item_desc, CATEGORY, item_size可以这样
select item_desc || category || item_size from plsql101_old_item;
SQL> select 'Item '|| Item_id|| 'is described as a'|| item_desc||'.' "Item Description Sentence"
2 from plsql101_old_item;
/'Item '
'is described as a'
'.' / 都是修饰的
|| 是字符连接符号
你的语句的意思
就是从表plsql101_old_item查询“Item”为列Item_id 的描述是('is described as a')
列item_desc
就是从表plsql101_old_item查询“Item”为列Item_id 的描述是('is described as a')
列item_desc的值
2 from plsql101_old_item;这个SQL语句没有函数,只是一个查询Item_id、item_desc两列值的语句,并对查询结果做了一下规范。
首先 || 是一个连接符号,把列值和语句中带单引号的字符串进行合并显示在查询结果中。'Item '、'is described as a' 和'.' 是要和列值进行连接的字符串,所以结果中每一行都会有这些字符