dbTalk Databases Forums  

Adding literal text to a query

mailing.database.mysql mailing.database.mysql


Discuss Adding literal text to a query in the mailing.database.mysql forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Laphan
 
Posts: n/a

Default Adding literal text to a query - 07-22-2004 , 05:44 PM






Hi All

This is probably very simple, but I just don't know the answer to it.

What I want to do is select 50 chars of a field and then put '...' at the
end of this selection, eg:

SELECT LEFT(DESC,50) + '...' FROM MyTable

The above doesn't work, but there must be some form of MySQL syntax that
lets me do this - right?

Thanks

Laphan



Reply With Quote
  #2  
Old   
Bill Karwin
 
Posts: n/a

Default Re: Adding literal text to a query - 07-22-2004 , 06:29 PM






Laphan wrote:
Quote:
What I want to do is select 50 chars of a field and then put '...' at the
end of this selection, eg:

SELECT LEFT(DESC,50) + '...' FROM MyTable
The + operator is used for string concatenation in Microsoft SQL Server
and some other products.

In MySQL, the way to do what you want is:

SELECT CONCAT(LEFT(DESC,50), '...') FROM MyTable

See http://dev.mysql.com/doc/mysql/en/String_functions.html for more
information.

Regards,
Bill K.


Reply With Quote
  #3  
Old   
Astra
 
Posts: n/a

Default Re: Adding literal text to a query - 07-23-2004 , 06:02 AM



Many thanks Bill

Much appreciated.

"Bill Karwin" <bill (AT) karwin (DOT) com> wrote

Laphan wrote:
Quote:
What I want to do is select 50 chars of a field and then put '...' at the
end of this selection, eg:

SELECT LEFT(DESC,50) + '...' FROM MyTable
The + operator is used for string concatenation in Microsoft SQL Server
and some other products.

In MySQL, the way to do what you want is:

SELECT CONCAT(LEFT(DESC,50), '...') FROM MyTable

See http://dev.mysql.com/doc/mysql/en/String_functions.html for more
information.

Regards,
Bill K.




Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.