Question: I have a query like this:

```
SELECT `*` 
  FROM (`threads` t, `members` m) 
 WHERE `m`.`id` = t.author 
   AND `t`.`type` = '0' 
   AND `t`.`category` = '1'

```

And basically what happens is that there is an ID field in both tables (members and threads) so what's happening is that the results array is getting messed up. IE: There is only one ID field which is being populated from the members table.

What I need to do is make the results with a prefix infront of their key name so I can distinguish between the two:
IE: Add 't.' to all thread fields and 'm.' to all members fields.

So results should be like: m.id = x, t.id = y
Instead, results at the moment are like: id = x (the id field from the thread table is completely overwritten by the one from the members table)

Answer: 
Use:

```
SELECT m.id AS x,
       t.id 'y' 
  FROM MEMBERS m
  JOIN THREADS t ON t.id = m.author
                AND t.type = '0'
                AND t.category = '1'

```

Column aliases are defined on a column by column basis - you can't use wildcards/etc.  

You can use the `AS` keyword, or simply enclose the column alias within single quotes *if* the column name doesn't contain special characters - use double quotes if it does. You can combine single/double quote usage with the `AS` keyword.

Do I have to List all the Columns?
----------------------------------

---

Yes, you have to list all the columns unless you like duplicate columns because you choose to use `m.*` or `t.*`. There is no convention in SQL that supports what you ask. `SELECT *` [is not an ideal practice - read this answer for details beyond this situation why](https://stackoverflow.com/questions/2128625/i-was-taught-that-select-from-table-is-bad-is-it-still-true/2128704#2128704).

Addendum
--------

---

I took the liberty of rewriting your query to use ANSI-92 JOIN syntax - your example used ANSI-89. There's no performance difference.
If you just want the id's to be separate, you can do

```
SELECT `*`, t.id as t_id, m.id as m_id
  FROM (`threads` t, `members` m) 
WHERE `m`.`id` = t.author 
  AND `t`.`type` = '0' 
  AND `t`.`category` = '1'

```

As the others said, it's a column alias.