私はlaravel 5.3を使用していますが、laravel queryメソッドでエラーのある結合クエリを残しています。 これは私の通常のクエリLaravel Left Join Query
SELECT bran.branchName,sch.schoolName From m_schoolbranch bran
LEFT JOIN m_students stu ON stu.schoolNo=bran.schoolNo AND stu.branchNo=bran.branchNo
LEFT JOIN m_school sch ON sch.schoolNo=stu.schoolNo where stu.userNo='0000000001';
であり、これは私がこの
->join('m_students', 'm_schoolbranch.branchNo', '=', 'm_students.branchNo')
のように置くので、私は、テーブルm_studentsに2つの列を一致させる必要がこれらのクエリでは、私の新しいlaravelクエリ
DB::table('m_schoolbranch')
->join('m_students', 'm_schoolbranch.schoolNo', '=', 'm_students.schoolNo')
->join('m_students', 'm_schoolbranch.branchNo', '=', 'm_students.branchNo')
->join('m_school', 'm_schoolbranch.schoolNo', '=', 'm_school.schoolNo')
->select('m_school.schoolName', 'm_schoolbranch.branchName')
->where('m_students.userNo',$userNo)
->get();
です
しかし、私はエラーを表示します...
エラーとは何ですか? – RustamG
Connection.php行のQueryException: SQLSTATE [42000]:構文エラーまたはアクセス違反:1066一意ではない表/別名: 'm_students'(SQL: 'm_school'.'schoolName'、' m_schoolbranch'.branchName'を選択します。 'm_schoolbranch'から' m_schoolbranch'内部結合 'm_students'から' 'm_schoolbranch'''schoolNo' =' m_students'''SchoolNo'内部結合 'm_schoolbranch'の' m_students'''branchNo' = 'm_students'.branchNo'内部結合' m_school '' m_schoolbranch'.'schoolNo' = 'm_school'.'schoolNo' on' 'm_students'.'userNo' = 0000000001) –