dan139
dan139

Reputation: 47

How to get table columns using a foreign key in SQL

so I have these tables:

a: id (primary key, foreign key to b), details, steps

b: id(primary key), field1, field2, field3, field4

How do I get all of the data of a and b using a select statement? would a "select * from a" automatically get all of the details of b associated with a? What would that specifically do?

Upvotes: 0

Views: 48

Answers (1)

Robert Columbia
Robert Columbia

Reputation: 6418

SELECT * FROM A
INNER JOIN B ON A.ID=B.ID

Change the join type (e.g. to LEFT OUTER JOIN, RIGHT OUTER JOIN, or FULL OUTER JOIN) if you want to include rows that don't have a match in the other table.

Upvotes: 2

Related Questions