title: search in sqlite database c++
body: <p>First of all this is my full code:</p>
  <pre><code>/*Getting user input and checking it using sqlite*/
  string data, sql;
  int id, rc;
  int al;
  do {
      cout &lt;&lt; &quot;Enter your id:&quot;;
      cin &gt;&gt; id;
  } while (id &gt; 9999999999 || id &lt; 1000000000);
  /*Creating a sqlite3 pointer in order to connect to the sql*/
  sqlite3* connection = nullptr;
  /*opening sql*/
  int result = sqlite3_open(&quot;sql.db&quot;, &amp;connection);
  /*Creating a query to search sql*/
  if (result) {
      cerr &lt;&lt; &quot;Error open DB &quot; &lt;&lt; sqlite3_errmsg(connection) &lt;&lt; std::endl;
  }
  else {
      cout &lt;&lt; &quot;Opened Database Successfully!&quot; &lt;&lt; std::endl;
  }
  sqlite3* query = nullptr;
  /*Searching database for id*/
  data = (&quot;CALLBACK FUNCTION&quot;);
  sql = (&quot;SELECT * FROM Doctors WHERE nationalCode = &quot; + to_string(id) + &quot; ;&quot;);
  /*start searching*/
  /*if sql found a document, then it will continue; else, it will make a new document then 
  it will continue*/
  rc = sqlite3_exec(connection, sql.c_str(), callback, (void*)data.c_str(), NULL);
  
  if (rc == SQLITE_OK) {
      cout &lt;&lt; &quot;Operation OK!&quot; &lt;&lt; endl;
      cout &lt;&lt; &quot;What do you want to do?&quot; &lt;&lt; endl;
      cout &lt;&lt; &quot;1:making a Visit&quot; &lt;&lt; endl;
      cout &lt;&lt; &quot;2:cancel your Visit&quot; &lt;&lt; endl;
      cout &lt;&lt; &quot;3:edit your Information&quot; &lt;&lt; endl;
      cout &lt;&lt; &quot;4:delete your Account&quot; &lt;&lt; endl;
      cin &gt;&gt; al;
      switch (al)
      {
      case 1:
          createVisit();
          break;
      case 2:
          cout &lt;&lt; &quot;Hello&quot;;
          break;
      case 3:
          editDoctor();
          break;
      case 4:
          cout &lt;&lt; &quot;Hello&quot;;
          break;
      default:
          cout &lt;&lt; &quot;Wrong number, Closing the Application&quot;;
          break;
      }
  }
  else {
      cout &lt;&lt; &quot;we can't find your information! Creating a new document right now&quot; &lt;&lt; endl
          &lt;&lt; &quot;+______________________________________________________________________________+&quot; &lt;&lt; endl;
      sqlite3_close(connection);
      createDoctor();
  }
  sqlite3_close(connection);
  </code></pre>
  <p>My problem is with these lines:</p>
  <pre><code>data = (&quot;CALLBACK FUNCTION&quot;);
  sql = (&quot;SELECT * FROM Doctors WHERE nationalCode = &quot; + to_string(id) + &quot; ;&quot;);
  /*start searching*/
  /*if sql found a document, then it will continue; else, it will make a new document then 
  it will continue*/
  rc = sqlite3_exec(connection, sql.c_str(), callback, (void*)data.c_str(), NULL);
  </code></pre>
  <p>I have a sqlite database and it's connected to my console app correctly but, when I'm searching for user input in the rows, no matter what it will run the if statement. I want to check if the user input is available. If the user input was available, run the <strong>if</strong> statement and if the user input was not available, then run the <strong>else</strong> statement.</p>
  <p>I believe there is something run with the &quot;rc&quot;. Can someone show me a proper way to do this?</p>