У меня есть две таблицы, таблица студентов и таблица Student_subject . I want to select students whose student_id appears on the student_subject table without duplicating students data -- only one row in the result set per student.
Table students
|student_id |name
|1 |John
|2 |James
Table subjects
id | subject_id | Студент_ид | субъект_name
1 | 2 | 1 | Математика
2 | 1 | 1 | английский
3 | 3 | 1 | Biology
< /p>
Мой код: < /p>
$this->db->select('*')
->from('students')
->where('student_id IN (select student_id from student_subject'));
< /code>
Я хочу отобразить только одну строку для Джона, как это:
< /p>
| Student_id | name
| 1 | John
< /p>
Подробнее здесь: https://stackoverflow.com/questions/424 ... e-to-at-le
Мобильная версия