Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7523423
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T02:47:55+00:00 2026-05-30T02:47:55+00:00

SELECT M.msg_id, M.uid_fk, M.message, M.created, U.fname, U.lname, M.uploads FROM messages M, users_friends F, users

  • 0
SELECT M.msg_id, M.uid_fk, M.message, M.created, 
U.fname, U.lname, M.uploads 
FROM messages M, users_friends F, users U  
WHERE M.uid_fk=F.friendID 
and F.userID = '5'
and status='2'

Building a facebook-like wall and want to grab messages(updates) from friends.

The query above returns an empty set, even though I’ve made sure there are messages from user 5 in the table.

Schema:

CREATE TABLE IF NOT EXISTS `messages` (
  `msg_id` int(11) NOT NULL AUTO_INCREMENT,
  `message` varchar(200) CHARACTER SET utf8 DEFAULT NULL,
  `uid_fk` int(11) DEFAULT NULL,
  `ip` varchar(30) DEFAULT NULL,
  `created` int(11) DEFAULT '1269249260',
  `uploads` varchar(30) DEFAULT NULL,
  PRIMARY KEY (`msg_id`),
  KEY `uid_fk` (`uid_fk`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=263 ;


CREATE TABLE IF NOT EXISTS `users` (
  `fname` varchar(15) NOT NULL,
  `lname` varchar(15) NOT NULL,
  `userID` int(11) NOT NULL AUTO_INCREMENT,
  `username` varchar(23) NOT NULL,
  `email` varchar(50) NOT NULL,
  `password` varchar(32) NOT NULL,
  `DOB` date DEFAULT NULL,
  `sex` varchar(1) DEFAULT NULL,
  `about` text NOT NULL,
  `location` varchar(20) DEFAULT NULL,
  `last_login` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `user_level` int(11) NOT NULL DEFAULT '0',
  `profile_image` varchar(200) NOT NULL,
  `profile_image_small` varchar(200) NOT NULL,
  PRIMARY KEY (`userID`)
 ) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=19 ;


CREATE TABLE IF NOT EXISTS `users_friends` (
  `userID` int(11) NOT NULL,
  `friendID` int(11) NOT NULL,
  `status` int(1) NOT NULL DEFAULT '0',
  PRIMARY KEY (`userID`,`friendID`),
  KEY `fk_users_has_friends_users1` (`userID`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T02:47:56+00:00Added an answer on May 30, 2026 at 2:47 am

    You are single quoting your INT values in the WHERE clause → ‘5’ & ‘2’.

    Also, try JOINs.

    SELECT  M.msg_id, 
            M.uid_fk, 
            M.message, 
            M.created, 
            U.fname, 
            U.lname, 
            M.uploads 
    FROM    messages M
    INNER JOIN  users_friends F ON F.friendID = M.uid_fk
        AND F.userID = 5
        AND F.status = 2
    INNER JOIN  users U ON U.userID = F.friendID;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have 3 Tables: Messages, Users, and Friends. Messages: msg_id, uid_fk, message, alert, created,
select tf.Id,tf.Name,tf.LName,tf.Rank,tf.Category where tf.Id not in (select fighter_id from tbl_player_fighter where league_id=91) and tf.Status
So I have the following group by SQL select count(*) as NO_OF_MSGS,FROM_USER,PROFILE_IMG,MSG from MESSAGES
SELECT * From `users` AS `User` LEFT JOIN `selections` AS `Selections` ON (`Selections`.`user_id` =
My query is as follows: SELECT ID,Bill_typeID,Cust_ID,Name,Reg_date,Account_Number,Amount,status FROM ( SELECT ID,Bill_typeID,Cust_ID,Name,Reg_date,Account_Number,Amount,status FROM Cust_Bill_Reg_M_Tbl UNION
I have a script which prints out messages from within a database. Each message
Consider the following tables: users messages ------------------- ---------------------- user_id avg_quality msg_id user_id quality -------------------
Consider the following tables: users messages ----------------- ----------------------- user_id messages msg_id user_id content -----------------
c = Conversation.joins(:messages).random >> Conversation Load (8.1ms) SELECT `conversations`.* FROM `conversations` INNER JOIN `messages`
I have a mysql query like this: $topicreplycount = mysql_query('SELECT COUNT(DISTINCT post_msg_id) FROM phpbb_attachments

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.