Sample Header Ad - 728x90

Convert rows into columns MySQL DataBase

0 votes
1 answer
64 views
I have two tables and I would like to generate a query relating the tables. Until now I have this query: SELECT Table1.*, table2.* FROM Table1 INNER JOIN table2 ON table2.FK_ID = Table1.ID but I return the 3 rows repeating the data in table 1. I would like my query to return the data as follows (see image) enter image description here Any suggestions to see if it is possible to make my requirement? Thank you! =============================== UPDATE =============================== I Tried with this query SELECT Table1.*, (SELECT Table2.Columna2 WHERE Table2.Columna4='ALTA') AS Name1, (SELECT Table2.Columna2 WHERE Table2.Columna4='ATENCION') AS Name2 FROM Table1 INNER JOIN Table2 ON Table1.ID = Table2.FK_ID GROUP BY Table1.ID but in my **Name2** always is **NULL**
Asked by Silvestre Silva (105 rep)
Feb 17, 2020, 10:50 PM
Last activity: Feb 23, 2020, 07:12 PM