Jump to content

Hi stuck at this any way around?


takn25

Recommended Posts

I have a table called data which stores name and other material and there is a table called

match.

 

Match has an auto incrementing id called match_id and a row called match_1 and match_2.

 

Ok what happens is an id which is unique from the data table is stored in match_1 and another

id which is unique from the data table is stored in match_2

 

For example

 

Match_id    match_1    match_2

40            1          2

 

40            2          1

 

Is there any way to retrive the data of both ids for instance in this case match_1 and match_2

based on the match_id being same? I tried a few joining queries but no luck for me could some one tell me how can I achieve this thanks.

 

Basically get name place etc details of match 1 and match 2  based on the match_id

Link to comment
https://forums.phpfreaks.com/topic/232650-hi-stuck-at-this-any-way-around/
Share on other sites

The thing is there is a name row in the data table and a place so if I do a while loop for fetching data

 

I dont understand how will I tell SQL that I want to fetch data of the match_1 and also match_2

I am able to fetch data of one of these not both with a join query but I dont know how can I fetch data

of both match_1 and match_2 in a single query is this possible?

 

For instance While ($row =mysql_fetch_assoc($result))

{

$name = $row['name'];

 

echo $name

}

 

If I echo $name it just shows either match_1 or match_2 and their data not both of them I dont know if I am making any sense could some one guide me thanks alot!

 

That is what my query is supposed to do.. I tested it with two rows with the same match_id and it returned the data from the data table for all the different match ids. OR just means it'll return rows that match either condition. I don't know the field names of your data table, so I just used match_id.

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.