List:General Discussion« Previous MessageNext Message »
From:Martin Ramsch Date:September 9 1999 6:17pm
Subject:Re: 2 questions 1) Limit x,y 2) select *,somefunction(x)
View as plain text  
On Thu, 1999-09-09 14:13:06 +0200, Patric de Waha wrote:
> Ok but now I need to know what was the row count if wouldn't limit
> the result [...]
> If possible I don't want to requery because the query can be very
> complicated and slow.

Two possibilities come to mind:
a) SELECT COUNT(*) FROM ...
     This gives you the number of result rows and often is
     faster than the actual select.

b) Using an appropriate temporary table:
   1st, INSERT INTO tmp SELECT ...
     All result rows are now stored in tmp and the number of
     rows can be obtained by the function mysql_num_rows()
     (exact syntax depends on your programing interface).
   2nd, SELECT * FROM tmp LIMIT ...
     Just get the readily prepared result rows.

Regards,
  Martin
-- 
Martin Ramsch <m.ramsch@stripped> <URL: http://home.pages.de/~ramsch/ >
PGP KeyID=0xE8EF4F75 FiPr=52 44 5E F3 B0 B1 38 26  E4 EC 80 58 7B 31 3A D7
Thread
2 questions 1) Limit x,y 2) select *,somefunction(x)Patric de Waha9 Sep
  • Re: 2 questions 1) Limit x,y 2) select *,somefunction(x)sinisa9 Sep
  • Re: 2 questions 1) Limit x,y 2) select *,somefunction(x)Martin Ramsch9 Sep
  • 2 questions 1) Limit x,y 2) select *,somefunction(x)Michael Widenius14 Sep