SQL inner join 3, 5, multiple tables with conditions, where clause, group by?

SQL inner join 3, 5, multiple tables with conditions, where clause, group by?

We have two tables “cats” and “dogs”.

1
2
3
4
5
6
7
8
<?php
$id = 1;
$requestSQL = mysqli_query($connection, "SELECT * FROM cats INNER JOIN dogs on (id = id_dog) where id = '$id'");
while ($row = mysqli_fetch_array($requestSQL))
{
echo ''.$row['name'];
}
?>

So I will explain.

The query will only trigger the results from the dogs table as the INNER JOIN will activate the second table, in our case “dogs”. They will get activated because the id and id_dog will match. Both tables will have the value set to “1”.

The $row[‘name’]; could just display the name of a dog that has the id_dog as 1;

Whatever command you will pull from your query will be from the dogs table. Count, delete or whatever.

Add a comment: