Kurashu
06-07-2005, 12:17 AM
I have a database arranged where I have several tables, all of them related one way or another.
The main table I querying information from is players. It contains the id, username, password, and some other data. It also has two fields labeled hijink and quote. These fields can be null, but if they are my select (see below) will skip over them. So I tried to use COALESCE to avoid this, but that failed as well.
SELECT p.name, p.joined, p.email, h.name, q.quote FROM players p, hijinks h, quotes q WHERE p.hijink = h.id AND p.quote = q.id;
If the Hijink and Quote fields in the players table is null then it will return null. So I thought that using COALESCE would be a good idea:
SELECT p.name, p.joined, p.email, COALESCE(h.name, 'none') AS hijink, COALESCE(q.quote, 'none') AS quote FROM players p, hijinks h, quotes q WHERE p.hijink = h.id AND p.quote = q.id;
That also returns NULL, much to my dismay.
Am I simply going to have to set an empty row in my hijinks and quotes tables and make their values the default for the hijinks and quotes tables? Or is there something that I'm doing wrong and I'm failing to see?
Hope to get some help soon, thanks in advance.
The main table I querying information from is players. It contains the id, username, password, and some other data. It also has two fields labeled hijink and quote. These fields can be null, but if they are my select (see below) will skip over them. So I tried to use COALESCE to avoid this, but that failed as well.
SELECT p.name, p.joined, p.email, h.name, q.quote FROM players p, hijinks h, quotes q WHERE p.hijink = h.id AND p.quote = q.id;
If the Hijink and Quote fields in the players table is null then it will return null. So I thought that using COALESCE would be a good idea:
SELECT p.name, p.joined, p.email, COALESCE(h.name, 'none') AS hijink, COALESCE(q.quote, 'none') AS quote FROM players p, hijinks h, quotes q WHERE p.hijink = h.id AND p.quote = q.id;
That also returns NULL, much to my dismay.
Am I simply going to have to set an empty row in my hijinks and quotes tables and make their values the default for the hijinks and quotes tables? Or is there something that I'm doing wrong and I'm failing to see?
Hope to get some help soon, thanks in advance.