Can be done with joins, make your self aware, you will find an answer ...
http://www.sitepoint.com/understanding-sql-joins-mysql-database/
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
My database contains information on people. Most of it is stored in the persons table, but there are other tables that contain additional information, e.g. protocols on interviews with these people. This is the simplified example of a typical query:
$query = DB::table("persons")
->leftjoin("protocols", "persons.id", "=", "protocols.personId")
->select ("persons.name", "protocol.text")
->where("protocol.id", ">", 10")
->get();
Let's assume there's a John Doe in my persons table and there's a protocol for him with id 3. The query won't return any of Johns data because 3 < 10.
But I need to get every person. The only thing I want to exclude are the protocols with an id <=10 themselves. In my example, I'd like the query to return John with an empty protocols.text. How can I achieve this?
Thanks Pida
Please or to participate in this conversation.