Question: Hi Good day everyone,

table\_1
--------

```
id       c2
-----------
id4     5     
id1     5
id3      4
id2     4

```

table\_2

```
-----------
id       c1
-----------
id1      5     
id2      5
id3      4
id4      4 

```

table\_3

```
-----------
id       c1
-----------
id3      5     
id1      5
id2     4
id4      4

```

After joining these three tables , I would to get as the following table.
target

```
----------------
id       c1c2c3
----------------
id1      555     
id2      544
id4      454
id3      445

```

If you don't mind help me , please.But my tables have only one unique key.My database is mysql 5.1.

Answer: 
Try this

```
SELECT T1.ID,concat(T2.c1,T1.c2,T3.c3 ) AS C1C2C3
FROM Table1 T1 JOIN Table2 T2 On T1.id =T2.id JOIN Table3 T3 On T3.id =T1.id
ORDER BY RIGHT(T1.ID,1)

```

**[Fiddle Demo](http://sqlfiddle.com/#!2/6a6bc8/3)**

---

**O/P:**

---

```
id       c1c2c3
----------------
id1      555     
id2      544
id3      445
id4      454

```
```
select t1.id, concat(t2.c1,t1.c2,t3.c3 ) as 'c1c2c3' from table_1 t1 inner
join table_2 t2 inner join table_3 t3 on t2.id=t1.id 
and t3.id=t1.id and t3.id=t2.id order by c1c2c3 desc

```