title: how to pass a value from one table to a new column of another table in sql?
body: <p>I created a table called users which stores the users' details. The user table has the fields call user_id(primary key), name, email, password, timestamps. After that, I created another table called 'test'. The test table columns are id(primary key auto increment),uid(user id),name,description(some random string).</p>
  <p>I wanted to take and pass the values of user_id and name into the uid and name columns of test table respectively. For that, I created a trigger function.By using the trigger function, I wanted to pass the values to the uid and name fields in 'test' table.  but I got the error as below.</p>
  <pre><code>  Traceback (most recent call last):
   File &quot;/home/sameera/anaconda3/envs/customerbot/lib/python3.6/tkinter/__init__.py&quot;, line 1705, in __call__
    return self.func(*args)
    File &quot;gui_bot.py&quot;, line 152, in send
     cursor.execute(insertion)
     File &quot;/home/sameera/.local/lib/python3.6/site-packages/pymysql/cursors.py&quot;, line 163, in execute
    result = self._query(query)
    File &quot;/home/sameera/.local/lib/python3.6/site-packages/pymysql/cursors.py&quot;, line 321, in _query
    conn.query(q)
    File &quot;/home/sameera/.local/lib/python3.6/site-packages/pymysql/connections.py&quot;, line 505, in query
    self._affected_rows = self._read_query_result(unbuffered=unbuffered)
    File &quot;/home/sameera/.local/lib/python3.6/site-packages/pymysql/connections.py&quot;, line 724, in _read_query_result
    result.read()
    File &quot;/home/sameera/.local/lib/python3.6/site-packages/pymysql/connections.py&quot;, line 1069, in read
    first_packet = self.connection._read_packet()
     File &quot;/home/sameera/.local/lib/python3.6/site-packages/pymysql/connections.py&quot;, line 676, in _read_packet
     packet.raise_for_error()
     File &quot;/home/sameera/.local/lib/python3.6/site-packages/pymysql/protocol.py&quot;, line 223, in raise_for_error
      err.raise_mysql_exception(self._data)
      File &quot;/home/sameera/.local/lib/python3.6/site-packages/pymysql/err.py&quot;, line 107, in raise_mysql_exception
      raise errorclass(errno, errval)
      pymysql.err.OperationalError: (1054, &quot;Unknown column 'test.uid' in 'where clause'&quot;)
  </code></pre>
  <p>The user table structure</p>
  <pre><code>     CREATE TABLE users(
          user_id int(20) PRIMARY KEY AUTO_INCREMENT,
          name varchar(255),
          email varchar(255),
          password varchar(255),
      )
  </code></pre>
  <p>The test table structure</p>
  <pre><code>   CREATE TABLE test(
          id int(20) PRIMARY KEY AUTO_INCREMENT,
          uid int(20),
          name varchar(255),
          description varchar(255)
      )
  </code></pre>
  <p>The trigger function</p>
  <pre><code>&quot;CREATE TRIGGER after_user_insert 
   AFTER INSERT 
          ON users FOR EACH ROW 
    BEGIN 
    INSERT INTO test(uid,name) 
        VALUES(NEW.user_id, NEW.name); 
     END;&quot;
  </code></pre>
  <p>Insertion function</p>
  <pre><code>&quot;&quot;&quot;INSERT INTO test(uid,name)
      Select name,user_id 
      From users
      Where users.user_id = test.uid
   &quot;&quot;&quot;
  </code></pre>
  <p>Can anyone explain the issue of the implementation. Thanks in advance.</p>