Jump to content

Sql Help Or Advice Need


rastaman46

Recommended Posts

Hey again well

 

im trying to call 2 tables from sql "t1" content name "t2" got all records im matching them up by ID

 

but result im get its row me in single rows Same name comes up few times diferent info same name

 

but i need if name is same and have few recods im like to display like this

 

"Name"-->first-->second-->and so on

 

not like

 

"Name" --> first

"Name" --> second

"Name" -->and so on

 

did im was clear???

Link to comment
Share on other sites

That is way JOINS work - for each matching record you get the data from t1 joined with matching data from t2.

 

To get what I think you want you will need to use GROUP BY coupled with GROUP_CONCAT()

 

SELECT t1.id, GROUP_CONCAT(t2.name SEPARATOR ', ') as names
FROM t1
INNER JOIN t2 ON t1.id = t2.id
GROUP BY t1.id

Edited by Barand
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.