Solved

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

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

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 …
I have been using r1soft Continuous Data Protection (http://www.r1soft.com/linux-cdp/) for many years now with the mySQL Addon and wanted to share a trick I have used several times. For those of us that don't have the luxury of using all transact…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

861 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

21 Experts available now in Live!

Get 1:1 Help Now