Question : MySQL JOIN gives empty column

I've seen a lot of this online but I can't grasp why my query is giving an empty column. Normally it's when there is NULL data and the query is matching empty instead. I have no NULL data.

I need "title" from node and "body" from node_revisions when node.type is 'bio'. nid is a column both have to join.

This works:
select node.title from node where node.type = 'bio'; # Gives all entries
select node_revisions.body from node_revisions; # Gives all body
I want to combine those queries

This doesn't work:
select node.title, node_revisions.body from node, node_revisions where node.nid = node_revisions.nid and node.type = 'bio'; # Displays all titles properly but Body is blank

This also works as a test.
select node.title, node_revisions.body from node, node_revisions where node.nid = node_revisions.nid and node.type = 'page'; # Displays title and body of pages instead of bio

If I do a != 'bio' instead of = 'bio' it gives proper data:
select node.title, node_revisions.body from node, node_revisions where node.nid = node_revisions.nid and node.type != 'bio'; # Displays title and body of pages that arent bios

I've also tried LEFT JOIN with the same result.

Answer : MySQL JOIN gives empty column

>> select node_revisions.body from node_revisions; # Gives all body

From inspection, there seems to be nothing wrong with the queries.
How many records are there in node_revisions and node; could you do a mysqldump?

select node.nid from node where node.type = 'bio';

Using the list above, run this 2nd query.

select * from node_revisions where node_revisions.nid in (....)

What do you get?
Random Solutions  
 
programming4us programming4us