Thursday, 4 October 2012

Join 2 Tables and show fields in only one of the tables without listing all in the query + MYSQL

Hi Fellas,

Yea, I know it's been a while! Been totally swamped with work and hanging out with my signifacant other ;)..

Okay I know you are all not interested in my romantic life so I will go straight to the point.

I promise this will be quick.

If you want to join 2 tables A and B; and you want to see all the fields in table A but none in table B, and you don't want to list the columns (who can be bothered, right?), WELL.....

All you have to do is:

SELECT A.* FROM A JOIN B on A.id = B.id;

This will return all the fields contained in table A.


There you have it, guys!!!! I told you this would be quick!
:)

No comments:

Post a Comment