Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/69.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql 使用联接参数sql转换fql查询_Mysql_Sql_Facebook Fql - Fatal编程技术网

Mysql 使用联接参数sql转换fql查询

Mysql 使用联接参数sql转换fql查询,mysql,sql,facebook-fql,Mysql,Sql,Facebook Fql,我这里有一段代码,它允许我提取喜欢某个特定页面的朋友,但我需要提取不喜欢某个页面的朋友 代码如下: $users = $facebook->api(array('method' => 'fql.query',         'query' => "SELECT uid, first_name, pic_small FROM user WHERE uid IN(     SELECT uid FROM page_fan WHERE page_id='41113392892143

我这里有一段代码,它允许我提取喜欢某个特定页面的朋友,但我需要提取不喜欢某个页面的朋友

代码如下:

$users = $facebook->api(array('method' => 'fql.query',
        'query' => "SELECT uid, first_name, pic_small FROM user WHERE uid IN(
    SELECT uid FROM page_fan WHERE page_id='411133928921438' AND uid IN (
        SELECT uid2 FROM friend WHERE uid1 = me()
    ))"));
我应该如何使用外部连接或SMTH获得这样的内容:

$users = $facebook->api(array('method' => 'fql.query',
            'query' => "SELECT uid, first_name, pic_small FROM user WHERE uid NOT IN(
        SELECT uid FROM page_fan WHERE page_id='411133928921438' AND uid IN (
            SELECT uid2 FROM friend WHERE uid1 = me()
        ))"));

鉴于它不支持外部联接或不支持内部联接,请尝试这样做(不确定这是否是最好的方法,但它应该可以工作)


免责声明-我使用PHP已经5年了,接触FQL也有很多年了-请告诉我是否有任何东西有效/无效(如果有效,我会感到惊讶:D)

谢谢你的回答。。。是的,我知道在FQL中没有外部连接,但我想我可以通过外部连接达到这个目的。。。嘿,但faebook不允许NOT IN参数..啊,好吧-我明白了,不知道它不支持NOT IN-不确定你是否可以这样做-你可能需要选择所有的参数,并在软件中筛选出你想要的参数…你能告诉我我该怎么做吗?通过php还是什么?我建议做两个查询——一个是获取所有的朋友,另一个是获取所有喜欢该页面的朋友,然后使用php查找所有不在“喜欢”列表中的朋友中的用户。我会更新答案是的,因为我理解逻辑,但我不擅长编写代码。。。
$likes = $facebook->api(array('method' => 'fql.query',
    'query' => "SELECT uid, first_name, pic_small FROM user WHERE uid IN(
SELECT uid FROM page_fan WHERE page_id='411133928921438' AND uid IN (
    SELECT uid2 FROM friend WHERE uid1 = me()
))"));

$allfriends = $facebook->api(array('method' => 'fql.query',
    'query' => "SELECT uid, first_name, pic_small FROM user WHERE uid IN (
    SELECT uid2 FROM friend WHERE uid1 = me()
)"));

// Loop through the rows
// I think there is a page where you can test FQL at developers.facebook.com, I'll see if I can find it on my phone so I can see what the JSON response looks like and fix this code, in the mean while see if this works

// Yeah so the code does this:
// Loop through each item in the $allfriends result, (put the contents of the row into the $friend variable
foreach( $allfriends as $friend )
{  
   // This bit I need to change, this is supposed to look in the $likes array to see if the UID is present, but it will be comparing the uid against the whole object - need to tweak this
   if( !in_array($friend['uid'], $likes) ) 
   {
       // Each friend that doesn't like the page should hit this part of the loop
       echo $friend['uid'];
   }                 
}