sql help getting data from all the followers ? ( like twitter if we follow )

Pentacle

New Member
K5e0Y.png
example if i have \[code\]follow tablecompany one ( cid = 1 ) following two ( cid = 2 )company one ( cid = 1 ) following three( cid = 3 )feeds tablecompany one ( cid = 1 ) type 'product' description 'hello ive updated a product';company two ( cid = 2 ) type 'product' description 'hello ive updated a product im from company 2';company three ( cid = 3 ) type 'shoutout' description 'hello ive i got a shoutout im company 3';company one ( cid = 1 ) type 'product' description 'hello ive updated my second product';\[/code\]question how do i get all the feeds.description from the company that my company ( example here is cid = 1 ) ?heres my simple pdo sql to get just mine.\[code\] $data['feeds']['cid'] = 1; return $this->db->fetchAll("SELECT feeds.type, feeds.$type, feeds.cid, feeds.time, companies.name FROM feeds, companies WHERE feeds.cid = :cid AND companies.cid = :cid ORDER BY feeds.fid DESC LIMIT 0, 5", $data['feeds']);this will displayhello ive updated a producthello ive updated my second product\[/code\]maybe something like this ? ( fail )\[code\] $data['feeds']['cid'] = 1,2,3; return $this->db->fetchAll("SELECT feeds.type, feeds.$type, feeds.cid, feeds.time, companies.name FROM feeds, companies WHERE feeds.cid = :cid AND companies.cid = :cid ORDER BY feeds.fid DESC LIMIT 0, 5", $data['feeds']);this should be displaying likehello ive updated a producthello ive updated a product im from company 2hello ive i got a shoutout im company 3hello ive updated my second product\[/code\]or simpler get feeds.description from each follow.following ( cid = 1,2,3,etc ) from me. ( cid = 1)or if twitter get all my friends status ( friends that i follow )edit*some good guys at irc mysql said to use joins. but i just dont get it.what i get is this\[code\]fetch all the follow.following from cid = me ( example cid = 1 )\[/code\]then\[code\]SELECT * FROM feeds WHERE feeds.cid = IN (2,3,cid that im following ( see follow.following )) \[/code\]anyone can give me an example for joins in this problem ?
 
Back
Top