?
Solved

MySQL using a SELECT sub-query with CONCAT to update a table

Posted on 2012-03-31
1
Medium Priority
?
718 Views
Last Modified: 2012-03-31
What is the correct syntax to include the result of this select query as part of an update. In other words i want an update query that uses this select query as a sub query.

SELECT `subscriberID`, `email`, 

CONCAT( 
SUBSTR(  `email` , 1, INSTR(  `email` ,  '@' ) -1 ) , 
SUBSTR(  `email` , 
	INSTR(  '@',  `email` ) +1, 
	INSTR(  '.',  `email` ) -1 - 
	INSTR(  '@',  `email` ) ) , 
	subscriberID ) AS uname

FROM newsletterSubscriber

Open in new window


thanks,

-hellenica
0
Comment
Question by:marcoullis
[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
1 Comment
 

Accepted Solution

by:
marcoullis earned 0 total points
ID: 37792025
never mind i figured it out on my own...

:-)

UPDATE newsletterSubscriber 
SET  `username` = (
SELECT CONCAT( 
SUBSTR(  `email` , 1, 
   INSTR(  `email` ,  '@' ) -1 ) , 
SUBSTR(  `email` , 
   INSTR(  '@',  `email` ) +1, 
   INSTR(  '.',  `email` ) -1 - 
   INSTR(  '@',  `email` ) ) , 
   subscriberID ) AS uname
)

Open in new window


-hellenica
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
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

800 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