title: How to include SELECT statement into INSERT INTO with concatenation & pdo
body: <p>I've recently started to code the shopping cart class and its repository(functions) and I had a problem with SELECT statement inside INSERT INTO statement and the problem is when I try to execute this code It executed but "SELECT statement always returning 0 in database " informed that productPrice is exist in database with its values</p>
  
  <p>the code:</p>
  
  <pre><code>class ShoppingCartRepo
  {
  
      public function addToCart($productId, $cartId)
      {
          $dbh = mySqlDatabase::getConnectionObject();
          $sql = "INSERT INTO cartitem (productId, cartId, singlePrice, quantity)
                        VALUES (:productId, :cartId, 'SELECT productPrice FROM products WHERE productId = :productId', 1)";
  
          $stmt = $dbh-&gt;prepare($sql);
          $data = array(
              ':productId' =&gt; $productId,
              ':cartId' =&gt; $cartId,
          );
          $stmt-&gt;execute($data);
          return $dbh-&gt;lastInsertId();
      }
  }
  </code></pre>