SQL query to return only filled table records

Asked

Viewed 91 times

0

How do I return my query only records that are filled? My table has some blank records that are returned by the association.

<?php
$consulta = $pdo->query("SELECT * FROM ws_so_wind, ws_soft_gallery WHERE id_soft = id_img AND id_soft = $id_soft ");
foreach ($consulta as $foto) {
?>
<a href="<?= BASEIMG ?><?= $foto['url_gallery']; ?> " data-lightbox="set" data-title="">
<img itemprop="screenshot" class="screenshot" src="<?= BASEIMG ?><?= $foto['url_gallery']; ?> "></a>
<?php } ?>
  • I suggest you read on INNER|LEFT|RIGHT JOIN, they will solve your problem =)

1 answer

1

There is a very nice explanation in this link: What is the difference between INNER JOIN and OUTER JOIN?

I believe this will solve your problem, but I strongly recommend studying the join clauses, will help you a lot in your journey :D

$consulta = $pdo->query("SELECT * FROM ws_so_wind INNER JOIN ws_soft_gallery ON id_soft = id_img WHERE id_soft = $id_soft");

Browser other questions tagged

You are not signed in. Login or sign up in order to post.