SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Oct 2009
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Need a Query Help

    I Developed 2 Table

    1)FriendTable

    Code:
     CREATE TABLE `friendtable` (            
                   `username` varchar(50) default NULL,  
                   `fusername` varchar(50) default NULL  
                 ) ENGINE=InnoDB DEFAULT CHARSET=latin1
    2)Msg Table

    Code:
     CREATE TABLE `msg` (                                      
              `msg` varchar(50) default NULL,                         
              `username` varchar(50) default NULL,                    
              `dt` date default NULL,                                 
              `id` int(50) unsigned NOT NULL auto_increment,          
              PRIMARY KEY  (`id`)                                     
            ) ENGINE=InnoDB AUTO_INCREMENT=15 DEFAULT CHARSET=latin1
    i need to get all the messages send by the fusername who is friend of username in friend table and messages send by username

    can anybody help me??

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,336
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    please provide sample data, preferably by dumping some rows from each table

    then show us what the query should return based on your sample data
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    SitePoint Member
    Join Date
    Oct 2009
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Friend Table Having Data

    username fusername
    ---------- ---------
    binumathew jesvin
    binumathew ddd
    Msg Table

    msg username dt id
    ---------- ---------- ---------- ------
    sdsdsd binumathew 0000-00-00 11
    sdsdsddsds binumathew (NULL) 12
    dddd jesvin 0000-00-00 13
    ddddd ddd 0000-00-00 14
    I need a result like this

    msg username dt id
    ---------- ---------- ---------- ------
    sdsdsd binumathew 0000-00-00 11
    sdsdsddsds binumathew (NULL) 12
    dddd jesvin 0000-00-00 13
    ddddd ddd 0000-00-00 14

  4. #4
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,336
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by binumathew1988 View Post
    I need a result like this
    see, that's why i was asking for sample data, so i can figure out what query you need

    for the sample data you provided, and the result you want, use this --
    Code:
    SELECT msg, username, dt, id FROM msg
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •