Scenario:
---------

I am working on a PHP/MySQLi aplplication where I have got 2 tables `attendance` and `students` .

`students` has fields: student\_id, fullname, phone,email,gender, department and level.

`attendance` table has fields: attendance\_id, student\_id, department\_id, level\_id.

I was able to fetch all students whose records are in the attendance table according to their department and level.

Question:
---------

Let's assume that I was able to fetch all students whose records are in the attendance table and are in 200L (with level\_id, 2) computer science (with department\_id, 4) department, if the list of the students present are much and it was paginated and I want to search for a particular student's fullname that's in attendance table in reference to student's table.

How will the SQL query be like? I tried the following query which didn't work.

```
$search_query = mysqli_query($db_connect, "SELECT *FROM attendance WHERE student_id=\"SELECT student_id FROM students WHERE fullname LIKE '%$student_fullname%'\";

```

Please help.