tags:

views:

50

answers:

1

How can I add the following code example 1 to example 2 without messing up my query.

Example 1

SELECT *
FROM users 
INNER JOIN users_articles ON users.user_id = users_articles.user_id
WHERE users.active IS NULL
AND users.deletion = 0

Example 2

SELECT users.user_id, users_articles.user_id, users_articles.title, articles_comments.article_id, articles_comments.comment, articles_comments.comment_id
FROM users_articles
INNER JOIN articles_comments ON users_articles.id = articles_comments.article_id
INNER JOIN users ON articles_comments.user_id = users.user_id
WHERE users.active IS NULL
AND users.deletion = 0
ORDER BY articles_comments.date_created DESC
LIMIT 50
A: 

I'm not sure exactly what you're asking, but does this help?

SELECT users.user_id, users_articles.user_id, users_articles.title, articles_comments.article_id, articles_comments.comment, articles_comments.comment_id
FROM users_articles
  INNER JOIN articles_comments ON users_articles.id = articles_comments.article_id
  INNER JOIN users ON articles_comments.user_id = users.user_id
WHERE users.active IS NULL
  AND users.deletion = 0
ORDER BY articles_comments.date_created DESC
LIMIT 50

Update

Is this what you want?

SELECT users.user_id, users_articles.user_id, users_articles.title, articles_comments.article_id, articles_comments.comment, articles_comments.comment_id
FROM users_articles
  INNER JOIN articles_comments ON users_articles.id = articles_comments.article_id
  INNER JOIN users ON articles_comments.user_id = users.user_id
    AND users.active IS NULL
    AND users.deletion = 0
ORDER BY articles_comments.date_created DESC
LIMIT 50;
SELECT *
FROM users 
  INNER JOIN users_articles ON users.user_id = users_articles.user_id
WHERE users.active IS NULL
  AND users.deletion = 0
Andrew Cooper
NO it's just the same as example 2.
blah
What, exactly, do you want the combined query to do?
Andrew Cooper
@Andrew Cooper I just want to know how to add the first select from example 1 to example 2 so in other words how do I run another select?
blah
Put a semicolon between the two select statements..
treeface