Jump to content

Join Data From Another Table Into Result


Staggan

Recommended Posts

Hello

 

I am trying to get data from another table added into my query to save using another query... here is my current query:

 


SELECT * from challenge where challenge_id = $challengeid AND status = 'completed' || status = 'forfeit'

 

I would like to add name from the team table where team_id = challenge.winner_team_id

 

How would I do this...

 

I am sure it is some kind of join, but when I tried I could not get the name field in my result

 

Any help would be much appreciated

 

Thanks

Hello,

 

That does what I want, but I need to change it slightly...

 

If challenge.winner_team_id is -1 I still need the results but need to set team.name = -1

 

So I need..

 

Everything from challenges based on status, and then IF winner_team_id exists in team table I need name, or I need to set name = -1

 

Can this be done?

 

Thanks

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.