Jump to content

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
https://forums.phpfreaks.com/topic/269543-sql-help-or-advice-need/
Share on other sites

but result im get its row me in single rows Same name comes up few times diferent info same name
You're going to have to rewrite this in English, this makes no sense at all.

 

Taking a complete shot in the dark: SELECT DISTINCT

 

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

Still guessing. If this is wrong you'll have to explain better or run with it yourself.

 

SELECT t1.betid, t1.bet_name, GROUP_CONCAT(t2.chosen_team SEPARATOR ', ') as teams
FROM t1
INNER JOIN t2 ON t1.betid = t2.betid
GROUP BY t1.betid

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.