0

この mysql クエリに追加して、何かが 'x' である場所をクエリに含めないようにする方法はありますか?

function get_newest_members() {
            global $connection;
            $query = "SELECT *
                        FROM ptb_users, ptb_profiles
                        WHERE ptb_users.account_type = \"member\" AND ptb_users.account_status = \"Active\" AND ptb_profiles.user_id = ptb_users.id
                        ORDER BY date_created DESC
                        LIMIT 0 , 6";
            $newest_set = mysql_query($query, $connection);
            confirm_query($newest_set);
            return $newest_set;
        }

exclude where ptb_profiles.user_id = '99999' を追加したいですか?

これは可能ですか?もしそうなら、誰かが私に見せてください。ありがとう。

4

3 に答える 3

2

これを条件に追加するだけです

SELECT ...
FROM   ...
WHERE  ... AND ptb_profiles.user_id <> '99999' 

補足として、二重引用符の代わりに単一引用符を使用する\必要がないため

$query = "SELECT *
          FROM ptb_users INNER JOIN ptb_profiles
                ON ptb_profiles.user_id = ptb_users.id
          WHERE ptb_users.account_type = 'member' AND 
                ptb_users.account_status = 'Active'    
          ORDER BY date_created DESC
          LIMIT 0 , 6";
于 2012-12-24T05:36:55.897 に答える
1

99999user_idを持つユーザーを結果から除外したい場合

追加するだけ

ptb_profiles.user_id != '99999' 
于 2012-12-24T05:37:31.453 に答える
1

これを試してみてください...

SELECT * FROM ptb_users, ptb_profiles WHERE ptb_users.account_type = \"member\" AND ptb_users.account_status = \"Active\" AND ptb_profiles.user_id = ptb_users.id AND ptb_profiles.user_id!='99999' ORDER BY date_created DESC LIMIT 0 , 6

于 2012-12-24T05:39:58.953 に答える