Solved

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

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

A lot of articles have been written on splitting mysqldump and grabbing the required tables. A long while back, when Shlomi (http://code.openark.org/blog/mysql/on-restoring-a-single-table-from-mysqldump) had suggested a “sed” way, I actually shell …
Fore-Foreword Today (2016) Maxmind has a new approach to the distribution of its data sets.  This article may be obsolete.  Instead of using the examples here, have a look at the MaxMind API (https://www.maxmind.com/en/geolite2-developer-package). …
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

707 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

18 Experts available now in Live!

Get 1:1 Help Now