Computer Webmaster Gaming Console Graphics Forum

Welcome to the Computer Webmaster Gaming Console Graphics Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact us.

MK PitStop Main Earn $25 Earn Money Posting Extras Members Blogs Image Hosting User Pages
Go Back   Computer Webmaster Gaming Console Graphics Forum > Webmaster Forum > Website Coding > Database
Register FAQ/Rules Become A V.I.P. Member Search Today's Posts Mark Forums Read

Database Database problems or need to ask a question? maybe something to do with sql injections or a database software question. Database topics cover MySQL, PostgreSQL, Oracle, SQL Server or anything else related to databases.

Google
Closed Thread
 
LinkBack Thread Tools Display Modes
Old 07-01-2007, 9:32 PM   #1
José Carlos Santos
 
José Carlos Santos's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default How to truncate fields (newbie)

Hi all:

Suppose that I have a table with fields which can be rather long string
of characters. For instance, it can be a table called library concerning
the books from a library and the fields might be the title and the
author of the books. If I type

SELECT title, author FROM library;

this might be hard to read on screen. Is it possible to display, say,
only the first 20 characters of each field?

Best regards,

Jose Carlos Santos
 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Advertisements
Old 07-01-2007, 9:32 PM   #2
Kai Ruhnau
 
Kai Ruhnau's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default How to truncate fields (newbie)

José Carlos Santos wrote:
> Suppose that I have a table with fields which can be rather long string
> of characters. For instance, it can be a table called library concerning
> the books from a library and the fields might be the title and the
> author of the books. If I type
>
> SELECT title, author FROM library;
>
> this might be hard to read on screen. Is it possible to display, say,
> only the first 20 characters of each field?


http://dev.mysql.com/doc/refman/5.0/...functions.html

<snip>

LEFT(str,len)

Returns the leftmost len characters from the string str.

mysql> SELECT LEFT('foobarbar', 5);
-> 'fooba'

</snip>

Greetings
Kai

--
This signature is left as an exercise for the reader.
 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Old 07-01-2007, 9:32 PM   #3
José Carlos Santos
 
José Carlos Santos's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default How to truncate fields (newbie)

On 01-05-2006 11:28, Kai Ruhnau wrote:

>> Suppose that I have a table with fields which can be rather long string
>> of characters. For instance, it can be a table called library concerning
>> the books from a library and the fields might be the title and the
>> author of the books. If I type
>>
>> SELECT title, author FROM library;
>>
>> this might be hard to read on screen. Is it possible to display, say,
>> only the first 20 characters of each field?

>
> http://dev.mysql.com/doc/refman/5.0/...functions.html
>
> <snip>
>
> LEFT(str,len)
>
> Returns the leftmost len characters from the string str.
>
> mysql> SELECT LEFT('foobarbar', 5);
> -> 'fooba'
>
> </snip>


Thanks for your reply, but I don't see how to use it in order to obtain
the effect that I mentioned: to get only the first 20 characters of each
field. For instance, it would be grat if

SELECT LEFT(title,20), LEFT(author,20) FROM library;

would do just that.

Best regards,

Jose Carlos Santos
 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Old 07-01-2007, 9:32 PM   #4
Peter H. Coffin
 
Peter H. Coffin's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default How to truncate fields (newbie)

On Mon, 01 May 2006 11:49:23 +0100, José Carlos Santos wrote:
> On 01-05-2006 11:28, Kai Ruhnau wrote:
>> http://dev.mysql.com/doc/refman/5.0/...functions.html
>>
>> <snip>
>>
>> LEFT(str,len)
>>
>> Returns the leftmost len characters from the string str.
>>
>> mysql> SELECT LEFT('foobarbar', 5);
>> -> 'fooba'
>>
>> </snip>

>
> Thanks for your reply, but I don't see how to use it in order to obtain
> the effect that I mentioned: to get only the first 20 characters of each
> field. For instance, it would be grat if
>
> SELECT LEFT(title,20), LEFT(author,20) FROM library;
>
> would do just that.


Did you try that? What error did you get? Or did you get the results you
were hoping for?

--
80. If my weakest troops fail to eliminate a hero, I will send out my best
troops instead of wasting time with progressively stronger ones as he
gets closer and closer to my fortress.
--Peter Anspach's list of things to do as an Evil Overlord
 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Old 07-01-2007, 9:32 PM   #5
José Carlos Santos
 
José Carlos Santos's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default How to truncate fields (newbie)

On 01-05-2006 17:00, Peter H. Coffin wrote:

>>> http://dev.mysql.com/doc/refman/5.0/...functions.html
>>>
>>> <snip>
>>>
>>> LEFT(str,len)
>>>
>>> Returns the leftmost len characters from the string str.
>>>
>>> mysql> SELECT LEFT('foobarbar', 5);
>>> -> 'fooba'
>>>
>>> </snip>

>> Thanks for your reply, but I don't see how to use it in order to obtain
>> the effect that I mentioned: to get only the first 20 characters of each
>> field. For instance, it would be grat if
>>
>> SELECT LEFT(title,20), LEFT(author,20) FROM library;
>>
>> would do just that.

>
> Did you try that? What error did you get? Or did you get the results you
> were hoping for?


I thought I had tried and got an error... but now I tried again and it
worked just fine. Thanks for your help and sorry for wasting your time.

Best regards,

Jose Carlos Santos
 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Old 07-01-2007, 9:32 PM   #6
Peter H. Coffin
 
Peter H. Coffin's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default How to truncate fields (newbie)

On Mon, 01 May 2006 18:02:51 +0100, José Carlos Santos wrote:
> On 01-05-2006 17:00, Peter H. Coffin wrote:
>
>>>> http://dev.mysql.com/doc/refman/5.0/...functions.html
>>>>
>>>> <snip>
>>>>
>>>> LEFT(str,len)
>>>>
>>>> Returns the leftmost len characters from the string str.
>>>>
>>>> mysql> SELECT LEFT('foobarbar', 5);
>>>> -> 'fooba'
>>>>
>>>> </snip>
>>> Thanks for your reply, but I don't see how to use it in order to obtain
>>> the effect that I mentioned: to get only the first 20 characters of each
>>> field. For instance, it would be grat if
>>>
>>> SELECT LEFT(title,20), LEFT(author,20) FROM library;
>>>
>>> would do just that.

>>
>> Did you try that? What error did you get? Or did you get the results you
>> were hoping for?

>
> I thought I had tried and got an error... but now I tried again and it
> worked just fine. Thanks for your help and sorry for wasting your time.


No wasted time; it just looked like exactly what I was expecting to see,
and it would have indicated a flaw in my understanding if it didn't
work. I would have liked to fix that flaw if I was wrong.

--
94. When arresting prisoners, my guards will not allow them to stop and grab a
useless trinket of purely sentimental value.
--Peter Anspach's list of things to do as an Evil Overlord
 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Featured Websites
Free Space
Free Space
Free Space Free Space
Closed Thread
Tags: , ,




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
SQL Search Multiple Fields ?? Nikolai Chuvakhin PHP 0 07-01-2007 3:18 PM
TRUNCATE and OPTIMIZE from Access to MySQL Mike Easter Database 5 06-10-2007 12:20 AM
Exporting BIT fields in MySQL 5 Adam Lipscombe Database 0 05-31-2007 8:48 PM
Can you add/remove fields.. Khai Database 4 05-31-2007 8:48 PM
Indexes on text fields Rune Database 0 05-31-2007 8:42 PM


Featured Websites




All times are GMT +1. The time now is 12:18 AM.


Powered by: vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.0.0
Cheap Computers
MK PitStop Copyright 2005 - 2008

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98