从多个表中选择

I am trying to select all rows from multiple tables(20 tables) but it isn't working for me, can some show me to select the first two? The tables have duplicate column names if that matters. I have read the manual and it says I can use JOIN but I couldn't get it.

What I tried:

stmt = $mysqli->prepare("SELECT * FROM table1, table2 where firstname LIKE ? ORDER BY id desc");
stmt->bind_param('s', $fname);
stmt->execute();

Joins are like so:

SELECT `something` FROM `table1` t1 JOIN `table2` t2 ON joinitem.t1 = joinitem.t2 ...
                                  ^--------table 1's id---------- ^    ^--column name

if you need data from each table that has a relationship with the other table provide the link in your WHERE clause

"SELECT * FROM table1, table2 where table1.id = table2.id AND firstname LIKE ? ORDER BY id desc");

If you want to mass select data from tables that doesn't have relationship to one another you can use a UNION but all the columns selected need to be the same type and column count needs to match

SELECT * FROM table1 where firstname LIKE 'x'
UNION ALL 
SELECT * FROM table2 where firstname LIKE 'x'

Probably, you have column id both in table1 and table2. Try to specify the table name explicitly in ORDER BY clause:

SELECT
    *
FROM
    table1, table2
WHERE
    firstname LIKE ?
ORDER BY
    table1.id desc

If you are sorting by table2.id, use it instead. If firstname is present in both tables, specify the table name in WHERE statement.