Jump to content

how show data form three tables in sql


wesley
 Share

Recommended Posts

Hello,

 

I want to show data from three tables with a join, but it doesn't work.

I have three tables: linktable, friends and carbrands.

The columns are friendnumer, lastname and carbrands.

The table linktable must show: column friendnumber.

The table friends must show: column lastname

and table carbrands must show column brand.

 

 

my sql is:

SELECT friendnumber,lastname, brand From linktable,friends,carbrands WHERE linktable.friendnumber = friends.lastname and friends.lastname = carbrands.brand ;

what is going wrong?

can someone help me?

 

thanks in advance.

Link to comment
Share on other sites

WHERE linktable.friendnumber = friends.lastname and friends.lastname = carbrands.brand
So, linktable.friendnumber, friends.lastname, and carbrands.brand all hold the same value? That sounds like 3 completely different names for the same value, but you're telling SQL to return rows where all of those fields have the same value.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...