How can I not display null values ​​in left join results?

I have a query that works well, but I'm trying to check if I can clean my results a bit.

The query pulls the fields to Stateand Fiber IDfrom my table with the name fiber_intake. Then it retrieves all the fields from the table hvi, where Fiber ID = GA in the fiber_intake table.

the code:

SELECT `fiber_intake`.`State`, `fiber_intake`.`Fiber ID`, `hvi`.*
FROM `fiber_intake`
 LEFT JOIN `hvi` ON `fiber_intake`.`Fiber ID` = `hvi`.`Fiber ID` 
WHERE (`fiber_intake`.`State` = 'GA')

It works great, except that it pulls all GA Fiber identifiers, even those that don't have hvi data in another table. So I get some results with a bunch of Nulls for hvi data.

Is there a way to exclude a Fiber id that is not related to the hvi table data?

Thank!

+3
source share
2

INNER JOIN LEFT [OUTER] JOIN.

OUTER JOIN.

SELECT `fiber_intake`.`State`, `fiber_intake`.`Fiber ID`, `hvi`.*
FROM `fiber_intake`
 INNER JOIN `hvi` ON `fiber_intake`.`Fiber ID` = `hvi`.`Fiber ID` 
WHERE (`fiber_intake`.`State` = 'GA')
+6

INNER JOIN.

+3

Source: https://habr.com/ru/post/1769559/


All Articles