I have two tables (Releases and Formats) and a field that is linked to both of them - bar_code
. The problem I am having is with this select statement:
SELECT
Release.name,
Release.default_upc,
Artist.name,
Artist.url_name,
Format.*
FROM
releases AS Release,
artists AS Artist,
formats AS Format
WHERE
Release.id IN(20015, 2414) AND
Artist.id = Release.artist_id AND
Format.bar_code = Release.default_upc
The issue is that when Release.default_upc = null
, no record will be returned. However, it is a valid behavior that default_upc
can be null, and if it is the query should not attempt to look for a Format with Format.bar_code = null
- instead just returning the other selected data.
Not actually sure this is 100% possible in MySQL, but open to any advice.