mySQL query

i have two varchar fields say

field1 varchar(20)
field2 varchar(4)

i want to return a result in the format field1 - field2

my query tries to add the two fields together

select (field1 + ' - ' + field2) as result from table

any help much appreciated
[308 byte] By [jim_scott] at [2007-11-19 14:06:01]
# 1 Re: mySQL query
hi...try this:

SELECT field1 - field2 as result FROM Table;

happy coding!
nikko at 2007-11-10 3:16:07 >
# 2 Re: mySQL query
Dear Jim_scott,

You can use the CONCAT function in MySql to get the same.

example:

select CONCAT(field1,"-",field2) FROM tablename;

this will give you the required result

Pramod S Nair
PramodsNair at 2007-11-10 3:17:07 >
# 3 Re: mySQL query
cheers for your replies

sorted
jim_scott at 2007-11-10 3:18:06 >