这是仅选择“1”值的记录的最佳方法吗?我无法使它有效:/
$results = mysqli_query($connecDB,"SELECT * FROM codes WHERE php = 1 AND java = 1 AND ruby = 1 ORDER BY id ASC");
+------+----------------+---------+--------+--------+
| ID | CODES | PHP | RUBY | JAVA |
+------+----------------+---------+--------+--------+
| 1 | ford | 1 | 0 | 0 |
+------+----------------+---------+--------+--------+
| 2 | seat | 1 | 1 | 1 |
+------+----------------+---------+--------+--------+
| 3 | fiat | 1 | 1 | 0 |
+------+----------------+---------+--------+--------+
| 4 | toyota | 1 | 0 | 0 |
+------+----------------+---------+--------+--------+
| 5 | chevrolete | 1 | 0 | 1 |
+------+----------------+---------+--------+--------+
答案 0 :(得分:1)
如果您的列不是int
,那么您的查询将无效,因此请在值周围包围引号并尝试
$results = mysqli_query($connecDB,"SELECT * FROM codes
WHERE php = '1' AND java = '1' AND ruby = '1' ORDER BY id ASC");
答案 1 :(得分:0)
SELECT codes FROM table_name WHERE php = 1 AND java = 1
可以使用AND / Or作为pr required来连接条件