I’m having a difficult time merging these queries to where I get the correct results. I need to get a result whether a user has commented on a post, voted on a post, or both. The first query gets all of the comments, the second all of the votes.
SELECT
usr_avatar,
usr_uname,
com_comment
FROM
posts_comments PC,
users U
WHERE
U.usr_id = PC.com_usr_id
AND
PC.com_post_id = 13
ORDER BY
PC.com_id DESC
SELECT
vote_usr_id
FROM
posts_votes
WHERE
vote_usr_id = 2
AND
vote_post_id = 13
CREATE TABLE IF NOT EXISTS `posts_comments` (
`com_id` int(11) unsigned NOT NULL auto_increment,
`com_post_id` int(11) unsigned NOT NULL,
`com_usr_id` int(11) unsigned NOT NULL,
`com_comment` varchar(255) collate utf8_unicode_ci NOT NULL,
PRIMARY KEY (`com_id`),
KEY `com_usr_id` (`com_usr_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=27 ;
ALTER TABLE `posts_comments`
ADD CONSTRAINT `posts_comments_ibfk_1` FOREIGN KEY (`com_usr_id`) REFERENCES `users` (`usr_id`);
CREATE TABLE IF NOT EXISTS `posts_votes` (
`vote_post_id` int(10) unsigned NOT NULL,
`vote_usr_id` int(10) unsigned NOT NULL,
`vote_date_added` datetime NOT NULL,
PRIMARY KEY (`vote_post_id`,`vote_usr_id`),
KEY `vote_date_added` (`vote_date_added`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;