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?
yes, it’s possible
can you tell us more about what you want to see as the data from the second table?
please do a SHOW CREATE TABLE for both tables
Thank you for the answer.
The structure of the 1st table isn’t important, I just want to get the total numbers of rows.
From the second table I select 2 columns, without WHERE clause.
For example, combining these 2 Selects in one query:
$sql1 = "SELECT COUNT(*) AS nrs FROM `table1`"; $sql2 = "SELECT `col1`, `col2` FROM `table2`";
After a few searches on the net I found a solution.
For those who has the same question, it is solved with this Query:
SELECT `col1`, `col2`, (SELECT count(*) FROM `table1`) AS nrs FROM `table2`