0

If I run a query specifying SQL_CALC_FOUND_ROWS so the total numbers of results is given back instead of the limited amount specified in the LIMIT clause, would it collapse (meaning the value of another simultaneous query would be returned instead of the current one). I do not know if querying a database at the same time from different clients would mix up the results, that is why I ask. Here's an example:

$query = $this->db->query("
    SELECT SQL_CALC_FOUND_ROWS r.title, r.raiting, u.display_name, c.category
    FROM reviews r
    INNER JOIN categories c
    ON r.category_id = c.id
    INNER JOIN users u
    ON r.user_id = u.id
    WHERE c.category = ?
    LIMIT ?, 7
", $category, $position);

Then I would run:

$this->db->query("
    FOUND_ROWS()
");

Again, if another query of the same kind was running by another client wouldn't FOUND_ROWS() return the value of that other client's query?

stacker
  • 43
  • 5
  • Databases have the notion of "connections" and "sessions" so queries do not interfere with each other (except performance-wise). Another query should not affect the results of a given query, including `SQL_CALC_FOUND_ROWS`. – Gordon Linoff Mar 06 '14 at 03:09
  • Perfect, explains it all, thank you very much. – stacker Mar 06 '14 at 03:14

0 Answers0