I’m new to PHP and MySQL -> I’m not good yet.
Today I came across the problem. I have a query that joins 2 tables ‘votes’ and ‘stories’
Here it is:
SELECT stories.*, SUM(votes.vote_value) as 'total_votes'
FROM stories JOIN votes ON stories.id = votes.item_name WHERE stories.st_date >= DATE_SUB(NOW(), INTERVAL 32 DAY)
GROUP BY stories.id
ORDER BY total_votes ASC LIMIT 10
I need to modify it so it only selects information from ‘stories’ table where field showing = 1
A simple query would look like this:
SELECT * FROM stories WHERE showing = 1
But I have no idea how to implement it the first query where I join two databases.
1 Answer