title: C++ SQLite3 how to know if select return 0 rows
body: <p>C++ SQLite3 how to know if select return 0 rows</p>
  
  <p>I have a select statement for SQLite3, how do I know that if after executing the sql statement, the result is 0 rows , no match found etc..</p>
  
  <p>How can i modify my code so that if 0 rows found, it will not execute the part where it put the result into a vector.</p>
  
  <p>My code below:</p>
  
  <pre><code>sqlstatement = "SELECT * from abe_account where department="+quotesql(department)+" AND name="+quotesql(name)+";";
  
  
      std::vector&lt; std::vector &lt; std:: string &gt; &gt; result;
      for( int i = 0; i &lt; 4; i++ )
      result.push_back(std::vector&lt; std::string &gt;());
  
  
      sqlite3_prepare( db, sqlstatement.c_str() , -1, &amp;stmt2, NULL );//preparing the statement
      sqlite3_step( stmt2 );//executing the statement
  
      while( sqlite3_column_text( stmt2, 0 ) )
  {
      for( int i = 0; i &lt; 4; i++ )
      result[i].push_back( std::string( (char *)sqlite3_column_text( stmt2, i ) ) );
      sqlite3_step( stmt2 );
      counter ++;
  }
  </code></pre>