|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
get data out of 4 tables
Hi...
I got 4 tables first table: columns r: username, userid, points, etc 2nd table: game_id, game_date, team1, team2, result1, result2 3rd table: user_id, game_id, bet_team1, bet_team2 4th table: team_id, team_name, team_pic my prob is to get some data out of different tables onto one site! I wanna have a site with a table on it listing all games with date, teamnames and results. Do u have any solutions or tips for me? |
|
#2
|
|||
|
|||
|
RE: get data out of 4 tables
The query would be something like this, not exactly but hopefully you can see the logic:
select table1.username, table2.game_id, table3.user_id, table4.team_id from table1, table2, table3, table4 Like I said not exactly but that is how you select different fields from multiple tables. You can still apply WHERE clauses, etc to your queries also. HTH |
|
#3
|
|||
|
|||
|
RE: get data out of 4 tables
Maybe some day mysql will support views.
I wrote something similar to that in perl;) Actually, probably more similar to clq/ogl |
|
#4
|
|||
|
|||
|
RE: get data out of 4 tables
I'd like nested selects before views.....
|
|
#5
|
|||
|
|||
|
RE: get data out of 4 tables
Views are cool, ever used them? They work just like a table. Nested selects tend to be a lot longer and have to think about them a little longer than a view. In either case, both work, so use what you have available
|
|
#6
|
|||
|
|||
|
RE: get data out of 4 tables
Thank u for your help...
but I got it in a different way.. like this: select s.*, m1.team_name as home, m2.team_name as guest from games s left join teams m1 on m1.team_id=s.team1 left join teams m2 on m2.team_id=s.team2 now I got another problem... how do i update my tables with data for different tables as one action? |
|
#7
|
|||
|
|||
|
RE: get data out of 4 tables
ok my table structure looks like this
table games --------------------------------------------------------------------- |game_id | game_day | date | team1 | team2 | result1 | result2 | |--------------------------------------------------------------------| | 1 | 1 | 2002-08-10 | 1 | 11 | 2 | 3 | | 2 | 1 | 2002-08-12 | 3 | 9 | 1 | 0 | | 3 | 2 | 2002-08-15 | 8 | 2 | 4 | 2 | |-------------------------------------------------------------------- table teams --------------------- |team_id | team_name| |-------------------- | 1 | FCK | | 2 | BVB | | 3 | HSV | |-------------------- table tip ----------------------------------------------------------- |tip_id | user_id |game_id| tip_team1 | tip_team2 | points | |----------------------------------------------------------- | 1 | 1 | 2 | 1 | 1 | 2 | | 2 | 5 | 3 | 3 | 4 | 1 | | 3 | 8 | 5 | 8 | 2 | 4 | |----------------------------------------------------------- table user --------------------- |user_id | user_name | |-------------------- | 1 | Joe | | 2 | John | | 3 | Alex | |-------------------- Now I want to get the data out of those tables to see the results of "Game_day 1" with infos: date, team names, the results and a changing site for the admin thus he can make entries on the results. for the users I got a login system. If they log in I need a query thus they can see the infos: date, teamnames, gameday, and they have to put in the result-tips. I would be really happy if u would help me!! THX |
|
#8
|
|||
|
|||
|
RE: get data out of 4 tables
nobody there to help me?
|
![]() |
| Viewing: Codewalkers Forums > Other Technologies > Database Help > get data out of 4 tables |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|