在mysql中以句子格式打印报告

时间:2013-02-07 16:32:35

标签: mysql concat mysql6

作为一个新手,我需要你的帮助。这次我试图在MYSQL 6.0中打印一个报告,显示每个分支&其位置采用以下格式:“分支名称”位于“城市名称”城市的“街道地址”。我还需要标签。这是我做过的事情。得到了结果:

SELECT CONCAT(name, ' ',  ' is located at', address, city, ' in the city of ')
FROM branch; 

我有一个名为地址的列,有6个街道地址。

1 个答案:

答案 0 :(得分:0)

根据您的评论,听起来您只需要以下内容:

SELECT 
  CONCAT(name, ' is located at ', address,' in the city of ',  city) As Label
FROM branch; 

请参阅SQL Fiddle with Demo

这会产生以下结果:

|                                                          LABEL |
------------------------------------------------------------------
| Robinhood is located at 1234 Robinhood Rd in the city of Salem |
|           New is located at 123 test dr in the city of Testing |