1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Multiple WHERE in MYSQL?

Discussion in 'General PHP and MySQL Discussions' started by TheBigK, Nov 7, 2015.

  1. TheBigK

    TheBigK Well-Known Member

    I wish to fetch data in the following format :

    Username | articles_last_month | total_articles

    Now, my query that lets me fetch the first two column looks like this :-
    Code:
    SELECT username, COUNT (blah) as articles_last_month FROM xf_thread
    INNER JOIN ....
    ON ....
    WHERE condition 1 AND date between (condition to choose first and last date of last month)
    
    It totally ignores the third column, the total_articles for which I will have to create an option to the WHERE condition. I'm wondering if it's possible to do it in a single query than write a separate query just to get the third column values?

    I tried appending 'AND' at the end of above query; but it creates an error.
     
  2. Daniel Hood

    Daniel Hood Well-Known Member

    Please show the full query or at least the real where clause. We can't troubleshoot this because you're omitting the part that isn't working, condition 1 isn't a valid constraint, and your between condition isn't legit either.
     
    Robust and Jake B. like this.

Share This Page