0

Hi guys,

im kind of curious, is there a query or some way to fuse two colums like
select a.col1,b.col1 from table1 a left join table2 b on a.id=b.table_a_id
then as a result i want to display only one column containing a.col1,b.col1

thanks =)

5
Contributors
10
Replies
14
Views
4 Years
Discussion Span
Last Post by code739
Featured Replies
  • That's what you posted in your OP, which consequently you said isn't what you want. Can you put the data into context? What is the relationship between table 1 and 2 for you to need a left join rather than inner join? Without explaining that, I can only assume the … Read More

0
select CONCAT(a.col1, ', ', b.col1) AS `fused` from table1 a left join table2 b on a.id=b.table_a_id
0

thanks for the try =)
what i want is 1 value per column not two separated in any delimeter

0

thanks for the try =)
what i want is 1 value per column not two separated in any delimeter

So if one column contained 'hot' and the other contained 'dog' you'd want 'hotdog', correct? If that's the case then blocblue's solution is correct. Merely remove the delimiter from the CONCAT function.

SELECT
  CONCAT(a.col1, b.col1) AS fused
FROM table1 AS a
LEFT JOIN table2 AS b
  ON a.id = b.table_a_id
0

no what i want is if one column contained 'dog' and the other column contan 'hot'
i want to display one column only; like

|tbl|

|dog|
|hot|

0

That's not what your original question asked for. If you want values from two different columns to display in the same column on seperate rows check out UNION instead.

You need to post more information about you database schemas if you require help with the query.

Edited by blocblue

0

yah sorry i think this line gets my problem differnce to you
select a.col1,b.col1 from table1 a left join table2 b on a.id=b.table_a_id

thanks anyway =)

1

That's what you posted in your OP, which consequently you said isn't what you want.

Can you put the data into context? What is the relationship between table 1 and 2 for you to need a left join rather than inner join? Without explaining that, I can only assume the result you want is:

SELECT a.col1 FROM table1 a LEFT JOIN table2 b ON (a.id = b.table_a_id)

UNION 

SELECT b.col1 FROM table1 a LEFT JOIN table2 b ON (a.id = b.table_a_id)

However, this will include NULL values where there isn't a joining value in table b.

Votes + Comments
for your patience :)
0

hi just mail me whatever you have doubts

Edited by happygeek: email deleted - keep all help in forums here at DaniWeb please

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.