簡體   English   中英

從表中選擇兩個字段與查詢生成器在ii中

[英]select two fields from thre table with query builder in yii

我有三個表,每個表都有“用戶名”和“密碼”字段。 我想從這三個中選擇所有用戶名和密碼字段,並將它們放在一個數組中。

我寫如下:

$command=Yii::app()->db->createCommand()
            ->select('email','password')
            ->from(array('mosqueculturalliablee','parent','school'))
            ->queryAll(); 

但錯誤提示電子郵件和密碼字段不明確。

我怎么寫這個查詢?

嘗試這個

 $command=Yii::app()->db->createCommand()
    ->select('mosqueculturalliablee.email,',
'mosqueculturalliablee.password,',
   'parent.email,','parent.password,','school.email,','school.password,')
    ->from(array('mosqueculturalliablee','parent','school'))
     ->queryAll();

如果您願意,還可以使用union()

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM