M
M
Mikhail Shipilov2015-02-19 20:15:20
PHP
Mikhail Shipilov, 2015-02-19 20:15:20

How to build a query in sql c count?

Help me to do, in general, there is a page with a key, there is a database in which there are three tables (connected id), one of them with a list of books, it has books with and without authors, how can I build a query to display books without authors with using count?

<?php
$g=$mysqli->query("SELECT COUNT(b_name) FROM books");
$result=[];
while($b=mysqli_fetch_assoc($g)){
  $result[]=$b;
}
var_dump($result);

b5efb59e637640ce94f55b2ac9df8502.png

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
Saboteur, 2015-02-19
@saboteur_kiev

In your screenshot, only ID AND b_name are visible. Is there an author column at all?
if there is, then
select * from books where author is null
should return all books where there is no author (author is the name of the column with the author)

A
Alexey Yakhnenko, 2015-02-19
@ayahnenko

With count you will display a number, not a book.
And in general esteem about where.

M
Mikhail Shipilov, 2015-02-19
@shipilovmisha

And how to display then books without authors?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question