D
D
doublench212014-12-07 09:12:42
PHP
doublench21, 2014-12-07 09:12:42

Why so many resulting rows?

SELECT COUNT(*) FROM page ORDER BY id LIMIT 0, 1
Result: 940
How can this be?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
Sergey, 2014-12-07
@begemot_sun

You obviously have a wrong use of LIMIT. LIMIT selects the specified number of rows from the result.
Your result is one line with the value in column 940. It is displayed accordingly.

I
iliyaisd, 2014-12-07
@iliyaisd

count(*) always returns one row, whether you set a limit or not. The limit here has nothing to do with line numbers. To get the last line you need to use something like
select * from page order by id desc limit 1

F
FanatPHP, 2014-12-07
@FanatPHP

Stop asking questions about small technical details that you are confused about.
Ask immediately about the main task, so that they explain to you how to do it CORRECTLY.
"I get one row from the database" - WHY?
"I want to know with the query above whether the last one is" - why?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question