Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to combine data from multiple tables using SQL?
    primarykey
    data
    text
    <p>I have following tables in my MySql database :</p> <pre><code>+----------------------------------------------+ PROJECT +----------------------------------------------| +----------------------------------------------| project_id | team_size | from_date +----------------------------------------------| 1 | 34 | 1 Dec 2010 +----------------------------------------------| 2 | 2 | 2 Jan 1902 +----------------------------------------------| 3 | 99 | 15 Aug 1947 +----------------------------------------------+ </code></pre> <hr> <pre><code>+----------------------------------------------+ Technologies +----------------------------------------------+ +----------------------------------------------+ technology_id | technology_name +----------------------------------------------+ 1 | Java +----------------------------------------------+ 2 | CPP +----------------------------------------------+ 3 | Hibernate +----------------------------------------------+ 4 | EJB +----------------------------------------------+ 5 | Python +----------------------------------------------+ 6 | Hadoop +----------------------------------------------+ 7424 | Perl +----------------------------------------------+ </code></pre> <hr> <p>To link <code>Project</code> and <code>Technologies</code> tables I have following table : </p> <pre><code>+----------------------------------------------+ Project_Technologies +----------------------------------------------+ +----------------------------------------------+ Project_ID | Technology_ID +----------------------------------------------+ 1 | 2 +----------------------------------------------+ 1 | 7424 +----------------------------------------------+ 2 | 1 +----------------------------------------------+ 2 | 3 +----------------------------------------------+ 2 | 4 +----------------------------------------------+ 2 | 5 +----------------------------------------------+ </code></pre> <p>I want to show data in one table in the form of rows and columns in UI. For example : </p> <pre><code>+---------------------------------------------------+ project_id | team_size | from_date | technologies |---------------------------------------------------| | 1 | 34 | 1 Dec 2010| CPP, Perl | |---------------------------------------------------| | 2 | 2 | 2 Jan 1902| Java, Hibernate, EJB, Python | |---------------------------------------------------| | 3 | 99 |15 Aug 1947| | +---------------------------------------------------+ </code></pre> <p>I am not able to form sql query to get something like this. I have tried following query which is giving me duplicate rows.</p> <pre><code>select pr.project_id,pr.team_size,pr.from_date,tech.technology_name from project pr, project_technologies ptech, technologies tl where pr.project_id=ptech.project_id and ptech.technology_id=tl.technology_id </code></pre> <p>I would like to know how to avoid duplicate rows? Currently this query is giving me 2 rows when project_id=1 and 4 rows when project_id=2</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload