Mysql select Count in table one and rows in table 2

Discussion in 'PHP/MySql' started by MarPlo, Aug 6, 2011.

  1. MarPlo Member

    Member Since:
    May 12, 2011
    Message Count:
    66
    Likes Received:
    6
    Hy,
    I have 2 MySQL tables.
    Can I make a single Select query to return the total number of rows in the first table ( COUNT(*) ) and the rows (their data) of the seccond table?
    And if this is posible, how does this query look like?
  2. MarPlo Member

    Member Since:
    May 12, 2011
    Message Count:
    66
    Likes Received:
    6
    Hy,
    For the peoples with the same problem, it is sollved with this code:
    Code (text):
    SELECT `useron`.`nume`, `useron`.`sid`, (SELECT count(*) FROM `users`) AS nrusers FROM `useron`
  3. webmaster.kwd New Member

    Member Since:
    Oct 11, 2011
    Message Count:
    30
    Likes Received:
    0
    Occupation:
    CEO
    Location:
    Pune India
    Thanks marPlo for sharing answer. We were also facing the same problem many times.

Share This Page