【发布时间】:2014-02-22 08:38:09
【问题描述】:
这让我快疯了。
我的查询忽略了 WHERE 子句,只输出所有结果。
我知道它仍在读取脚本,因为当我将脚本更改为荒谬的内容时,例如 WHERE user=xxx is throws back an error。
帮助?
$data = mysql_query(
"SELECT
tbl_messages.id as msgID,
tbl_messages.from_user as msgFROM,
tbl_messages.to_user as msgTO,
tbl_messages.the_message as msgMESSAGE,
tbl_messages.status as msgSTATUS,
tbl_messages.date as msgDATE,
tbl_messages.subject as msgSUBJECT,
tbl_users.id as usrID,
tbl_users.name as usrNAME,
tbl_photos.profile as photosPROFILE,
tbl_photos.photo_link as photoLINK,
tbl_photos.default_photo as photoDEFAULT
FROM tbl_messages
LEFT JOIN tbl_users
ON tbl_messages.from_user = tbl_users.id
LEFT JOIN tbl_photos ON tbl_photos.profile = tbl_users.id
WHERE tbl_messages.to_user = 65 AND tbl_photos.default_photo IS NULL OR tbl_photos.default_photo = '1'
ORDER BY status DESC")
【问题讨论】:
标签: where