[英]mysql :Select last 10 entry with column value TRUE and 10 witt value FALSE without repeating
[英]how to select both true and false column value in mysql
我有一個名為 file_download 的表。 我需要顯示
select * from file_download where downloaded = 1;
select * from file_download where downloaded = 0;
下面是示例表。
+----+----------+---------+------------+ | pk | filename | file | downloaded | +----+----------+---------+------------+ | 1 | aaa.txt | aaa.txt | 1 | | 2 | bbb.txt | aaa.txt | 1 | | 3 | ccc.txt | aaa.txt | 0 | | 4 | ccc.txt | aaa.txt | 1 | | 5 | ccc.txt | aaa.txt | 0 | | 6 | ccc.txt | aaa.txt | 0 | +----+----------+---------+------------+
提前致謝...
有三種方法可以做同樣的事情
使用 OR(成本更低)
select * from file_download 其中下載 = 1 或下載 = 0
使用 IN(簡短而准確的方式)
select * from file_download where download in (0, 1);
使用不為空(不推薦的方式)
select * from file_download 其中下載的不為空
感謝您的回復...我已經完成了
select * from file_download where download <> ?
? - 對於隨機輸入值 (0, 1)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.