In this example we are just fetching two columns data and also set limit 5. You can set your own limits and also set your own columns.
How to build where query in Yii2
$data = (new \yii\db\Query())
->select(['columnName1', 'columnName2'])
->from('table_name')
->where(['columnName' => 'value'])
->limit(5) //set limit
->all();