Ansipants
Ansipants

Reputation: 35

Linking mysql tables

i'm fairly new to mysql/php and i', trying to grab data from 2 tables:

  1. organization_dep (id, orgid, depname )
  2. organization (id, orgname )

what I am trying to do is link the tables and echo the results so it comes as table with two columns: organization Name and organization Department Name

Thanks for any help!

Upvotes: 0

Views: 418

Answers (1)

hsan
hsan

Reputation: 1559

The "JOIN" tag on your question is actually the right key word.

SELECT
    org.orgname,
    dep.depname
FROM
    organization_dep dep
    INNER JOIN organization org
        ON dep.orgid = org.id

Read more about joining tables in the MySQL Documentation.

Upvotes: 2

Related Questions