Solved

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

Posted on 2012-03-31
1
694 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
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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

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 …
Both Easy and Powerful How easy is PHP? http://lmgtfy.com?q=how+easy+is+php  Very easy.  It has been described as "a programming language even my grandmother can use." How powerful is PHP?  http://en.wikipedia.org/wiki/PHP  Very powerful.  But a…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

786 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