MySQL Forums
Forum List  »  General

Re: How to get the row count
Posted by: Thomas
Date: March 31, 2006 12:41AM

No both is not working in that way I meant here my SQL statement

SELECT m.*, r.*
FROM t_caveats m, v_invoice r, t_user u
WHERE n_caveats_id= ?
AND m.n_invoice_id = r.n_id
AND r.n_cust_id = ?
AND m.n_user_id = u.n_id
AND r.n_diff_day > 0
ORDER BY r.c_adr_cust

And I need in this statement the number of rows like


SELECT m.*, r.*, FETCHED_ROWS()
FROM t_caveats m, v_invoice r, t_user u
WHERE n_caveats_id= ?
AND m.n_invoice_id = r.n_id
AND r.n_cust_id = ?
AND m.n_user_id = u.n_id
AND r.n_diff_day > 0
ORDER BY r.c_adr_cust

Another way would be


SELECT m.*, r.*, rec.rec_count
FROM t_caveats m, v_invoice r, t_user u, (
SELECT count(*) rec_count
FROM t_caveats m, v_invoice r, t_user u
WHERE n_caveats_id= ?
AND m.n_invoice_id = r.n_id
AND r.n_cust_id = ?
AND m.n_user_id = u.n_id
AND r.n_diff_day > 0
) rec
WHERE n_caveats_id= ?
AND m.n_invoice_id = r.n_id
AND r.n_cust_id = ?
AND m.n_user_id = u.n_id
AND r.n_diff_day > 0
ORDER BY r.c_adr_cust

But this is not very nice

Options: ReplyQuote


Subject
Written By
Posted
March 30, 2006 07:54AM
Re: How to get the row count
March 31, 2006 12:41AM
March 31, 2006 04:25AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.