Solved

Adding Extra Characters to query output

Posted on 2011-03-20
4
294 Views
Last Modified: 2012-06-27
Hey guys,

I would like to find out how to add text to the starting and/or the end of a column output.....


query example --
SELECT price, category, item_image
FROM table_name

before --
9.99, electronic_item, item_image.jpg

after --
9.99, electronic_item, item_image_90.jpg

What I'm looking for is to have for e.g "_90" suffixed or put in behind of all image records that are produced from the query results..
0
Comment
Question by:greeneel
  • 2
4 Comments
 
LVL 12

Assisted Solution

by:Amick
Amick earned 250 total points
ID: 35177283
SELECT price, category, item_image||'_90'
FROM table_name
0
 
LVL 38

Assisted Solution

by:Aaron Tomosky
Aaron Tomosky earned 100 total points
ID: 35177297
The end of a string is easy. Select image_name+'_90' from table
The harder part is to insert it before the .jpg. Using left and search it can be done. You can also do replace to replace .jpg with _90.jpg
0
 
LVL 2

Accepted Solution

by:
michael_madsen earned 150 total points
ID: 35177300
This query:

SELECT price, category, item_image+'_90'
FROM table_name

will add '_90' to all values in [item_image] field, but if you have the field values to be: 'item_image.jpg', the result would be: 'item_image.jpg_90', which isn't what you want.

What you could do is:

SELECT price, category, replace(item_image, '.jpg', '_90.jpg')
FROM table_name
0
 
LVL 12

Assisted Solution

by:Amick
Amick earned 250 total points
ID: 35177323
This is the MySQL way to do it:

SELECT price, category, concat(item_image,'_90')
FROM table_name 

Open in new window


The SQL Server / Microsoft Access way
SELECT price, category, item_image+'_90'
FROM table_name 

Open in new window

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This guide whil teach how to setup live replication (database mirroring) on 2 servers for backup or other purposes. In our example situation we have this network schema (see atachment). We need to replicate EVERY executed SQL query on server 1 to…
Foreword This is an old article.  Instead of using the MySQL extension that was used in the original code examples, please choose one of the currently supported database extensions instead.  More information is available here: MySQLi / PDO (http://…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

930 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now