Join two table

luzz

Registered User.
Local time
Today, 01:58
Joined
Aug 23, 2017
Messages
346
Hi all, may i know how to perform join on two table?


I tried using join but it is not the result that i want.
Below is my SQL Code:
SELECT *
Code:
FROM Table1 INNER JOIN Table2 ON Table1.PO = Table2.PO;

I want the table to show all the fields in both table 1 and table 2
 

Attachments

  • Table1.png
    Table1.png
    9.4 KB · Views: 99
  • Table2.png
    Table2.png
    7 KB · Views: 103
Try this SQL Code:

Code:
SELECT Table1.*, Table2.* FROM Table1 INNER JOIN Table2 ON Table1.PO = Table2.PO;
 
Last edited:
Try this SQL Code:

Code:
SELECT Table1.*, Table.* FROM Table1 INNER JOIN Table2 ON Table1.PO = Table2.PO;

Hi, it did join all my fields together but it show duplicate column. How can i get rid of it?
 

Attachments

  • Untitled.png
    Untitled.png
    23.1 KB · Views: 98
Hi, it did join all my fields together but it show duplicate column. How can i get rid of it?

Yes it will do as you have PO in both tables.
So the easiest solution is use .* for Table1 then enter all the fields individually from Table2 except PO ... OR do the same the other way round
 
Not sure why your first query didn't work - it should show all fields as does Colins

you can just ignore one or the other PO column in your form or report
 
Not sure why your first query didn't work - it should show all fields as does Colins

you can just ignore one or the other PO column in your form or report

Hi CJ
The original code by Luzz was
Code:
SELECT * FROM Table1 INNER JOIN Table2 ON Table1.PO = Table2.PO;

That will of course only show the fields from Table1
 
SELECT * FROM Table1 INNER JOIN Table2 ON Table1.PO = Table2.PO;

That will of course only show the fields from Table1
you sure about that? On what basis?
 
you sure about that? On what basis?

I just tried it to make absolutely sure of my facts !!!
I even tried it for Select Table2.* separately to Table1.*

Perhaps you have an example that brings in fields from both tables without listing any from the second table.
If so, I'd like to see it as it would potentially save lots of work in future!!!!
 
OP said

I want the table to show all the fields in both table 1 and table 2
SELECT * FROM will do that

Perhaps you have an example that brings in fields from both tables without listing any from the second table.
both tables without listing from second table? don't understand
 
Hi CJ

Sorry - we were at cross purposes.

You are quite right in saying that:
Code:
SELECT * FROM Table1 INNER JOIN Table2 ON Table1.PO = Table2.PO;

gives exactly the same results as

Code:
SELECT Table1.*, Table2.* FROM Table1 INNER JOIN Table2 ON Table1.PO = Table2.PO;

As the OP had included Table1.*, I added to that whereas you stripped it down
 

Users who are viewing this thread

Back
Top Bottom