xyla
Posts: 17
|
| Posted: 06/16/2006, 8:20 AM |
|
I would like to see 2 column in a listbox. I use the following sql...
SELECT city_id, (city_name & ' - ' & country_name) as 2cols FROM training_cities ORDER BY 2cols
Don't get errors just "0" zero's in the 2cols column
_________________
http://xyla.nl | Your Solution Provider |
 |
 |
mrachow
Posts: 509
|
| Posted: 06/16/2006, 9:30 AM |
|
Where and how do you specify your SQL statement?
E.g. could you show us please the complete syntax.
_________________
Best regards,
Michael |
 |
 |
xyla
Posts: 17
|
| Posted: 06/16/2006, 9:41 AM |
|
In the listbox data source I used the following SQL...
SELECT city_id, (city_name & ' - ' & country_name)
AS 2cols
FROM training_cities
ORDER BY 2cols
Listbox Bound Column set to city_id
Text Column set to 2cols
I used the MySQL VARCHAR (50) data type. Could this be a problem?
_________________
http://xyla.nl | Your Solution Provider |
 |
 |
E43509
Posts: 283
|
| Posted: 06/16/2006, 10:14 AM |
|
Looks like code I've done are you sure it is bringing back data?
|
 |
 |
xyla
Posts: 17
|
| Posted: 06/16/2006, 11:22 AM |
|
Posted this question in the MySQL forum also.
The following answer i received, works fine...
SELECT city_id, concat(city_name, ' - ', country_name) AS 2cols
FROM training_cities
ORDER BY 2cols
_________________
http://xyla.nl | Your Solution Provider |
 |
 |
peterr
Posts: 5971
|
| Posted: 06/16/2006, 11:36 AM |
|
This syntax works for me with MS Access:
SELECT city_id, (city_name & ' - ' & country_name) as 2cols FROM training_cities ORDER BY city_name;
But keep in mind that different databases may use different syntax, so it's best to mention right away which database you're using.
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com |
 |
 |
mrachow
Posts: 509
|
| Posted: 06/19/2006, 12:01 AM |
|
MySQL uses the common string concatenation || for logical or.
But the other default function CONCAT is uses as expected.
CONCAT(city_name, CONCAT(' - ', country_name))
should do.
_________________
Best regards,
Michael |
 |
 |
WKempees
|
| Posted: 06/19/2006, 3:03 AM |
|
CONCAT_WS( ' - ', city_name, country_name )
|
|
|
 |