[MySQL 5.0.45-community-nt-log] [Err] 1093 - You can't specify target table

Hello guys,

I am currently getting the error

[Err] 1093 - You can’t specify target table ‘tbl_login’ for update in FROM clause

when trying to run the below query.

Any help would be much appreciated!

Many thanks in advance for your time.

UPDATE tbl_login
SET login1 = (
	SELECT
		SUBSTRING_INDEX(EMAIL, '@', 1) AS login1
	FROM
		tbl_login
)
WHERE
	1
AND ISNULL(login1);

you can’t select the same table you’re trying to update

in this particular instance, you don’t need the subquery at all

UPDATE tbl_login
   SET login1 = SUBSTRING_INDEX(email,'@',1)
 WHERE login1 IS NULL

p.s. when i saw your thread in the forum list, this is what showed –

[MySQL 5.0.45-community-nt-log] [Err] 1

you can probably shorten your database identification, and if you put it at the end rather than at the beginning, the topic of your thread will actually be readable in the forum list –

Error 1093 - You can’t specify target table [MYSQL 5]

thanks a lot!