title: Yii2 Restful API : display the data from database into JSON format with specific condition SQL
body: <p>I'm working on Yii2 restful API and want to display the data into JSON format. This is my <strong>structure database</strong>:</p>
  
  <pre><code>TABLE `volunteer`(
  `volunteer_id` int(11) NOT NULL auto_increment,
  `state_id` int(11) null
  `nama` varchar(200) null
  
  TABLE `state`(
  `state_id` int(11) NOT NULL auto_increment,
  `state` varchar(225) null
  </code></pre>
  
  <p>Basically, when I run at browser with specific ID = 1 (<a href="http://localhost/KDMA/web/index.php/volunteers/1" rel="nofollow">http://localhost/KDMA/web/index.php/volunteers/1</a>) the data will display like this: </p>
  
  <pre><code>{
     "volunteer_id": "1",
     "state_id":"12",
     "nama": "Bentong",
  }
  </code></pre>
  
  <p>that result is display the data from volunteer_id = 1. <strong>So, what I want to do right now is display the data from state_id, not volunteer_id</strong>. For example in SQL:</p>
  
  <pre><code>SELECT * FROM volunteer where state_id = 12;
  </code></pre>
  
  <p>What are the ways that can solve my problem?</p>