Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9122911
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T06:12:52+00:00 2026-06-17T06:12:52+00:00

I am using the following to only select the first 40 characters from a

  • 0

I am using the following to only select the first 40 characters from a column

SELECT SUBSTRING(w.item_title,1,40) as title from tableName blah blah

What I really want to do though is:

If w.item_title is over 40 characters, return only the first 40 and append with … else just return w.item_title as it is

Is this possible at SELECT stage and should it be done there? Or should it be processed after the fact?

I am using JS to display the results.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T06:12:53+00:00Added an answer on June 17, 2026 at 6:12 am
    SELECT SUBSTR(INSERT(w.item_title, 41, 3, '...'), 1, 43)
      FROM ...
    

    See the manual on the INSERT() String function for examples.

    INSERT(str,pos,len,newstr)
    Returns the string str, with the substring beginning at position pos
    and len characters long replaced by the string newstr. Returns the
    original string if pos is not within the length of the string.
    Replaces the rest of the string from position pos if len is not within
    the length of the rest of the string. Returns NULL if any argument is
    NULL.

    EDIT
    Last parameter of SUBSTR should be 43 as pointed out by Joachim.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to mock only the GetValue method of the following class, using Moq:
In DB2, using the following left join select a.deptno, a.deptname, b.empno from #dept a
I'm using the following statement SELECT TOP 5 rootcause, COUNT(IIF(accountability=Team 1,1,0)) FROM MOAQ WHERE
I am using the following code: $result = mysql_query(SELECT * FROM table LEFT JOIN
Using the following example, I need to filter out the line containing 'ABC' only,
How do I do the following using built-in modules only? I have a list
I've been using the following code to create various struct, but only give people
Basically, I'd like to do the following, only using Common Lisp instead of Python:
I was using the following code to retrieve HTML snippets from a database table
I am using the following method to return values from the SQLite Database. public

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.