Solved

MySQL Table update returning error

Posted on 2013-06-05
7
548 Views
Last Modified: 2013-08-20
Hi,

I am using following SQL

update email a, contact b
set a.email =  CONCAT('abcd+' ,b.first_name,', ',b.last_name, '@gmail.com')  
where a.contact_id=b.id

I have an error
 #1442 - Can't update table 'contact' in stored function/trigger because it is already used by statement which invoked this stored function/trigger.

There are no triggers on the table.

Thanks
0
Comment
Question by:crazywolf2010
[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
7 Comments
 
LVL 4

Expert Comment

by:apreed
ID: 39222652
Is this a stored function? If so, check the SQL code that calls this function and make sure "contact" is not already used as an alias in there within the same session.
0
 

Author Comment

by:crazywolf2010
ID: 39222676
Hi,
This is not stored function at all. I am running it under phpmyadmin.

Thanks
0
 
LVL 5

Accepted Solution

by:
sriramiyer earned 167 total points
ID: 39222796
you can try this,

update email a, contact b
set a.email =  CONCAT('abcd' ,b.first_name,b.last_name, '@gmail.com')  
where a.contact_id=b.id
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 23

Assisted Solution

by:nemws1
nemws1 earned 333 total points
ID: 39223944
Try using the newer style syntax for such things (instead of doing a cross join)

UPDATE email AS a
  JOIN contact AS b
    ON a.contact_id = b.id
SET a.email = CONCAT('abcd', b.first_name, b.last_name, '@gmail.com')
;

Open in new window

0
 

Author Comment

by:crazywolf2010
ID: 39224037
Exact same error
0
 
LVL 15

Expert Comment

by:Jagadishwor Dulal
ID: 39224378
What is the scenario I don't understand your question are you updating using two tables ?? can you post image for your table??
0
 
LVL 23

Assisted Solution

by:nemws1
nemws1 earned 333 total points
ID: 39226126
Is there a trigger on the 'contact' table?  I'm assuming when you originally stated "There are no triggers on the table." you meant the 'email' table.

Can you run this SQL command just to double-check? (replace 'your_database_name' with the name of your database)

SELECT TRIGGER_NAME
    , EVENT_OBJECT_TABLE
FROM information_schema.TRIGGERS
WHERE TRIGGER_SCHEMA = 'your_database_name'
;

Open in new window

0

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

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…
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 …
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

632 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