SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Jul 2008
    Posts
    40
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Exclamation #1093 - You can't specify a target table for update in FROM clause

    Hi,

    I am currently getting the error "#1093 - You can't specify target table 'bookings' 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.

    Richard

    Code MySQL:
    BEGIN;
    INSERT INTO users (firstname, lastname, dob, email, mobile, uni, address, postcode) 
    VALUES (firstname, lastname, 1980-10-10, email, mobile, 1, address, postcode);
    INSERT INTO bookings (eid, tid, pid, uid, value) 
    VALUES (4, 2,
    (SELECT pid FROM promoters, tickets WHERE promoters.id = tickets.pid AND 2 BETWEEN start AND end AND eid = 4), 
    (SELECT users.id AS uid FROM users  WHERE users.reg_date IN (SELECT bookings.reg_date FROM bookings)),  12);
    COMMIT;

  2. #2
    reads the ********* Crier silver trophybronze trophy longneck's Avatar
    Join Date
    Feb 2004
    Location
    Tampa, FL (US)
    Posts
    9,854
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    well, you can't SELECT from the same table you're trying to INSERT in to when using the INSERT ... VALUES construct.

    an easy way around this problem is to rewrite the VALUES clause into a SELECT statement instead. see http://dev.mysql.com/doc/refman/5.1/...rt-select.html
    Check out our new Industry News forum!
    Keep up-to-date with the latest SP news in the Community Crier

    I edit the SitePoint Podcast


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
  •