1

Being a newbie I need your help again. This time I'm trying to print a report in MYSQL 6.0 that shows each branch & its location in the following format: The 'branch name' is located at 'street address' in the city of 'city name'. I also need labels. Here's what I've done & gotten as a result:

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

I got a column named address with 6 street addresses.

Taryn
  • 242,637
  • 56
  • 362
  • 405
  • Can you post some sample data and then the desired result? – Taryn Feb 07 '13 at 16:58
  • In a table named branch with data coming from 'name', 'address', and 'city', I want to show the name of the branch, it's street address, & name of the city it's in, so that it comes out in .sentence form, e.g. The Robinhood branch is located at 1234 Robinhood Rd in Salem. – S Elizabeth Starkey Feb 07 '13 at 17:40
  • you need to select only one record. Share the table schema please. – जलजनक Feb 07 '13 at 18:15

1 Answers1

1

Based on your comments, it sounds like you just want the following:

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

See SQL Fiddle with Demo.

This generates a result of:

|                                                          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 |
Taryn
  • 242,637
  • 56
  • 362
  • 405