Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Adding Extra Characters to query output

Posted on 2011-03-20
4
Medium Priority
?
298 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:Eaddy Barnes
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 12

Assisted Solution

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

Assisted Solution

by:Aaron Tomosky
Aaron Tomosky earned 400 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 600 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 1000 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

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Question has a verified solution.

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

As a database administrator, you may need to audit your table(s) to determine whether the data types are optimal for your real-world data needs.  This Article is intended to be a resource for such a task. Preface The other day, I was involved …
This article shows the steps required to install WordPress on Azure. Web Apps, Mobile Apps, API Apps, or Functions, in Azure all these run in an App Service plan. WordPress is no exception and requires an App Service Plan and Database to install
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

722 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