Hi,
I am new in yii2 I am trying write query with join to get all column from two tables
but not understand what the problem
modelName::find() joinWith(‘secondTable’,)
->where([‘firstTable.id’=>$id])
->all();
but when print query show as SELECT firstTable.* FROM firstTable LEFT JOIN secondTable ON firstTable.id = secondTable.id WHERE firstTable.id=‘5’
when trying remove firstTable. from begin of query its done but
I want know why firstTable. added to query
Yii2’s ActiveRecord uses 2 queries to retrieve the records when you specify a related table. The SQL you showed is the 1st one that retrieves the main table. And you could find the 2nd one which retrieves the records in secondTable.