Welcome Guest, Not a member yet? Register   Sign In
What's wrong with this code? =/
#1

[eluser]emily12[/eluser]
Hi, I'm trying to get 4 article tables, 4 comments tables, 1 article type table, and a user table to get all of the comments in my project. But I can't seem to understand what's wrong with even the most basic code.

Code:
SELECT * FROM `entertainment` b LEFT OUTER JOIN `entertainment_comments` ON (0) WHERE  cme_articles_article = `earticleid`
UNION ALL
SELECT * FROM `articles` b RIGHT OUTER JOIN `articles_comments` ON (0) WHERE  cm_articles_article = `articleid`

This is the most recent version of the simplified mysql query and it gives me the following error:

#1222 - The used SELECT statements have a different number of columns


I had been advised to use http://dev.mysql.com/doc/refman/5.0/en/create-view.html as reference but I can't seem to understand how to use it. Can anyone please help me? I have until monday before this project is due and I already had my teacher extend it from friday so it will be interesting to see what happens until then Tongue

Thank you for your time!



EDIT: Here's the idea behind what I hope the final thing for that module will be
Quote:articles contains the article themselves for standard articles
categories contains the categories for the standard articles section
comments contains the comments that were published for these articles

entertainment contains the article themselves for the Entertainment section
entertainment_type is the article type for entertainment, this is used to know if it's information / review / etc. full urls are generated thanks to this
entertainment_comments contains the comments that were published for the entertainment section

users is the user list. it is joined by the comment author when needed. The standard articles uses the categories table to define the url similarly to what the entertainment_type does. Why is it this way? Because I wanted to learn something about migrations, and this was a little over my head lol
Quote:User
Comment body
Date (sorted by newest)
Category OR category type


Messages In This Thread
What's wrong with this code? =/ - by El Forum - 06-06-2012, 12:25 PM
What's wrong with this code? =/ - by El Forum - 06-06-2012, 12:44 PM
What's wrong with this code? =/ - by El Forum - 06-06-2012, 01:26 PM
What's wrong with this code? =/ - by El Forum - 06-06-2012, 01:32 PM
What's wrong with this code? =/ - by El Forum - 06-06-2012, 01:34 PM
What's wrong with this code? =/ - by El Forum - 06-06-2012, 01:44 PM
What's wrong with this code? =/ - by El Forum - 06-06-2012, 01:46 PM
What's wrong with this code? =/ - by El Forum - 06-06-2012, 01:51 PM
What's wrong with this code? =/ - by El Forum - 06-06-2012, 02:08 PM
What's wrong with this code? =/ - by El Forum - 06-06-2012, 02:50 PM
What's wrong with this code? =/ - by El Forum - 06-06-2012, 04:16 PM
What's wrong with this code? =/ - by El Forum - 06-06-2012, 04:22 PM
What's wrong with this code? =/ - by El Forum - 06-06-2012, 05:02 PM
What's wrong with this code? =/ - by El Forum - 06-06-2012, 05:45 PM



Theme © iAndrew 2016 - Forum software by © MyBB