It is the first time I´m using SELECT
queries without having an input. I would like to check a table for duplicates. As a result I only need to count the result.
So I have this:
SELECT
`field a`, `field b`, `field c`
FROM
table
WHERE
`a` AND `b` AND `c`
GROUP BY
duplicates
HAVING
COUNT(duplicates) > 1
would this check the table for duplicates when the structure is like:
field a | field b | field c
a b c
a b c
d e f
And how can I get the result? Would it be just num_rows
or do I get an integer as a result back from the query?
Normally I use num_rows
to fetch the result from the query like that:
$query = $db->query("SELECT ...");
$result = $query->num_rows;
if ($result !== 0 ){do something}
There usually should be a difference between num_rows
and the result because if I would count by using num_rows
it will return 2
because 2 have the condition a AND b AND c
so I would think that the query from above would return 1
as a result for 1
duplicate found. Or am I wrong?
Thanks alot.