我想根据另一个表中的某些值从表中选择一些行。我有这个代码:
$row = Yii::app()->cre->createCommand()
->from('test')
->queryAll();
我应该为此写入什么 where() 子句?
解释:
我有表 test
和相关的 test2
,其中有 test_id
字段和 compare_id
字段。我需要从 test
获取所有行,其中 compare_id = 1
最佳答案
我认为它应该与连接一起使用:
$row = Yii::app()->cre->createCommand()
->from('test')
->join('test2','test2.compare_id = test.test_id')
->queryAll();
关于php - 根据子表中的字段值从数据库中选择行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26507004/