SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Evangelist cms9651's Avatar
    Join Date
    Mar 2010
    Posts
    407
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    [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.

    Code:
    UPDATE tbl_login
    SET login1 = (
    	SELECT
    		SUBSTRING_INDEX(EMAIL, '@', 1) AS login1
    	FROM
    		tbl_login
    )
    WHERE
    	1
    AND ISNULL(login1);
    Thanks you very much for your help
    I'm really happy for your quickly answer.
    Good bye

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,263
    Mentioned
    60 Post(s)
    Tagged
    3 Thread(s)
    you can't select the same table you're trying to update

    in this particular instance, you don't need the subquery at all
    Code:
    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]
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    SitePoint Evangelist cms9651's Avatar
    Join Date
    Mar 2010
    Posts
    407
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    thanks a lot!
    Thanks you very much for your help
    I'm really happy for your quickly answer.
    Good bye


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •