xkLi0 opened a new issue, #36201:
URL: https://github.com/apache/shardingsphere/issues/36201

   ## Question
   
   I have a table A, and I have already implemented data sharding by writing 
statements using the distsql method. However, I now need to query data from 
table A and import it into table B, but the SQL prompts an error: 
   
   SQL error [20034] [44000]: The table inserted and the table selected must be 
the same or bind tables.
   
   How should I use distsql to implement table binding?
   
   For example:
   TABLE: customer is new table, 
   TABLE: msg is source table, using the distsql method to implement data 
sharding
   
   INSERT INTO customer
   (id,user_id, recent_chat_time, create_time, creator)
   SELECT
       t.id + 1 as id,
       t.staff_id AS user_id,
       t.max_send_time AS recent_chat_time,
   FROM (
       SELECT 
           id,
           user_id,
           MAX(send_time) AS max_send_time
       FROM 
           msg
       WHERE 
           is_mark = 0
       GROUP BY 
           user_id
   ) t
   ON DUPLICATE KEY UPDATE
       recent_chat_time = recent_chat_time,
       modify_time = NOW(),
       modifier = -1;
   
   when i run this sql, return error:
   SQL ERROR: [20034] [44000]: The table inserted and the table selected must 
be the same or bind tables.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: 
[email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to