Solved

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

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

Upcoming Webinar: Securing your MySQL/MariaDB data

Join Percona’s Chief Evangelist, Colin Charles as he presents Securing your MySQL®/MariaDB® data on Tuesday, July 11, 2017 at 7:00 am PDT / 10:00 am EDT (UTC-7).

Question has a verified solution.

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

Foreword This is an old article.  Instead of using the MySQL extension that was used in the original code examples, please choose one of the currently supported database extensions instead.  More information is available here: MySQLi / PDO (http://…
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL several years ago, it seemed like now was a good time to update it for object-oriented PHP.  This article does that, replacing as much as possible the pr…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

717 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