book_id|title
1 |apple
2 |banana
3 |volkswagen
genre_id|name
1 |fruits
2 |cars
id|book_id|genre_id
1 | 1 | 1
2 | 3 | 2
3 | 2 | 1
我想按字母顺序显示所有类型为水果的书籍,我的代码是:
<?php
include "mysql-connect.php";
$sql =
"SELECT title
FROM books
INNER JOIN multiple ON book.book_id = multiple.book_id
VALUES ('1')";
if (mysqli_query($conn, $sql)) {
while($row = $result->fetch_assoc()) {
echo "" . $row["title"]."<br>";
}
} else {
echo "0 results";
}
$conn->close();
?>
更改值后仍显示0个结果
答案 0 :(得分:0)
这是什么?
SELECT title
FROM books
INNER JOIN multiple
ON book.book_id = multiple.book_id VALUES ('1')
在我看来,WHERE
在哪里,看起来像不是有效的SELECT查询。典型值是用于插入
INSERT INTO multiple (id) VALUES (1)
可能您需要类似
SELECT title
FROM books
INNER JOIN multiple
ON book.book_id = multiple.book_id
WHERE
some_column = 1
这是什么some_column
,我不知道。