0

私は正常に動作するこのmysqlクエリを持っています:

$query = "SELECT
          USER.USER_ID, NAME, SURNAME, EMAIL, STATUS, PHOTO
          FROM FRIENDLIST, USER, USER_PROFILE
          WHERE FRIENDLIST.FRIEND_ID = ANY (
              SELECT FRIEND_ID FROM FRIENDLIST WHERE USER_ID=".$userID."
          )
          AND APPROVED='YES'
          AND USER.USER_ID=FRIENDLIST.FRIEND_ID
          AND USER.USER_ID=USER_PROFILE.USER_ID
          UNION
          SELECT
          USER.USER_ID, NAME, SURNAME, EMAIL, STATUS, PHOTO FROM FRIENDLIST, USER, USER_PROFILE
          WHERE FRIENDLIST.FRIEND_ID = " . $userID . "
          AND APPROVED = 'YES'
          AND USER.USER_ID=FRIENDLIST.USER_ID
          AND USER.USER_ID=USER_PROFILE.USER_ID";

クエリにさらにいくつかのフィールドを追加すると、「ドキュメントが空です」というエラーが表示されます。

$query = "SELECT
          USER.USER_ID, NAME, SURNAME, EMAIL, STATUS, PHOTO, gender, cposition, rinterest, about
          FROM FRIENDLIST, USER, USER_PROFILE
          WHERE FRIENDLIST.FRIEND_ID = ANY (
              SELECT FRIEND_ID FROM FRIENDLIST WHERE USER_ID=" . $userID . "
          )
          AND APPROVED='YES'
          AND USER.USER_ID=FRIENDLIST.FRIEND_ID
          AND USER.USER_ID=USER_PROFILE.USER_ID
          UNION
          SELECT
          USER.USER_ID, NAME, SURNAME, EMAIL, STATUS, PHOTO
          FROM FRIENDLIST, USER, USER_PROFILE
          WHERE FRIENDLIST.FRIEND_ID = ".$userID."
          AND APPROVED='YES'
          AND USER.USER_ID=FRIENDLIST.USER_ID
          AND USER.USER_ID=USER_PROFILE.USER_ID";

新しいフィールドはテーブルに属しUSER_PROFILEます。

4

1 に答える 1