例如,如果我有
follow table
company one ( cid = 1 ) following two ( cid = 2 )
company one ( cid = 1 ) following three( cid = 3 )
feeds table
company 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';
问题
我如何从我的公司获得所有 feeds.description(例如这里是 cid = 1)?
这是我的简单 pdo sql 来获取我的。
$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 display
hello ive updated a product
hello ive updated my second product
也许是这样的?( 失败 )
$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 like
hello ive updated a product
hello ive updated a product im from company 2
hello ive i got a shoutout im company 3
hello ive updated my second product
或更简单地从我的每个 follow.following ( cid = 1,2,3,etc ) 中获取 feeds.description。( cid = 1) 或者 twitter 获取我所有朋友的状态(我关注的朋友)
编辑*
irc mysql 的一些好人说要使用连接。但我就是不明白。我得到的是这个
fetch all the follow.following from cid = me ( example cid = 1 )
然后
SELECT * FROM feeds WHERE feeds.cid = IN (2,3,cid that im following ( see follow.following ))
任何人都可以给我一个加入这个问题的例子吗?