我的数据库中有一个表,目前包含2条记录。除了唯一ID和uploaded_date之外,每条记录中的数据完全相同。
我正在运行一个简单的查询来查找表中的数据,但是,它只返回其中一行。
数据如下:
id from_user to_user filename uploaded_date
1 ABC123 XYZ123 filename1.pdf 2015-03-18 14:28:32
2 ABC123 XYZ123 filename.pdf 2015-03-18 14:52:19
查询如下:
SELECT *
FROM (`file_uploads`)
WHERE `from_user` = 'ABC123'
AND `to_user` = 'XYZ123'
AND `folder_path` = './uploads/ABC123'
AND `is_deleted` = 0
AND `to_user_archived` = 0
ORDER BY `upload_date` DESC
它是否构建在MySQL中,因为它认为行是重复的?
任何帮助表示感谢。
答案 0 :(得分:0)
试试这个
SELECT * FROM `file_uploads`
WHERE `from_user` = 'ABC123'
AND `to_user` = 'XYZ123'
AND `filename` = 'filename1.pdf'
ORDER BY `uploaded_date` DESC