Reputation: 13
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
I wanted to show all books with genre as fruits on alphabetical order my code is:
<?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();
?>
Still showing 0 results after changing the values
Upvotes: 0
Views: 33
Reputation: 21671
Whats this?
SELECT title
FROM books
INNER JOIN multiple
ON book.book_id = multiple.book_id VALUES ('1')
Doesn't look like a valid SELECT query to me, where is the WHERE
. Typical Values is uses in insert
INSERT INTO multiple (id) VALUES (1)
Probably you need something like this
SELECT title
FROM books
INNER JOIN multiple
ON book.book_id = multiple.book_id
WHERE
some_column = 1
What this is some_column
I have no idea.
Upvotes: 0