Writing query for multiple tables in php

前端 未结 2 1976
轮回少年
轮回少年 2020-12-07 06:40

I am writing my last query for my homework, but I am stuck on it right now. This query requires me to take information from 2 tables instead of 1. I am confused on how to ge

相关标签:
2条回答
  • 2020-12-07 07:00

    As mentionned in the above comment, you have to do an SQL (inner) join in this case. So you'll have something like:

    SELECT name, indep_year, region 
    FROM lab2.country 
    JOIN lab2.country_language
    ON lab2.country.country_code = lab2.country_language.country_code
    WHERE …
    
    0 讨论(0)
  • 2020-12-07 07:02

    A good starting point would be the PostgreSQL tutorial, in particular, joins between tables.

    You must perform an inner join between the two tables to link them together into a bigger virtual row that you can then filter and select individual columns from.

    The tutorial provides better examples than I can.

    0 讨论(0)
提交回复
热议问题