Quantcast
Channel: dBforums – Everything on Databases, Design, Developers and Administrators
Viewing all articles
Browse latest Browse all 13329

Problem with Search command!

$
0
0
Hi All,
I'm designing a simple website on ASP & Access, I have a problem when using search method to display the players with their current teams.

Databases as below:
Players
P_ID,P_Name,.....etc (Player Info with P_ID as Primary Key)
Teams
T_ID,T_Name,....etc (Team Info with T_ID as Primary Key)
Team_Player
TP_ID,P_ID,T_ID,TP_DateJoined,TP_DateLeft,TP_Jerse yNo,...etc (With TP_ID as primary Key, while P_ID,T_ID as Foreign keys)

In the teams database there are clubs & National teams as well, so a player might be at 2 teams in the same time.
I wrote this sql statement to search for a player :
Code:

Player = Request.Form("Player")
"select * FROM Teams INNER JOIN (Players INNER JOIN
Team_Player ON Players.P_ID = Team_Player.P_ID)
 ON Teams.TEAM_ID = Team_Player.Team_ID WHERE  P_Name Like '%"&Player&"%'
ORDER BY P_Name,Players.P_ID desc"

the problem is when i click the search button, if there is someone who plays for his national team the name will be duplicated in two rows one with his current club and another with national team.
for ex. when i search for "Messi" the results appears as below:
L. Messi - Photo - Forward - 24/June/1987 - FC Barcelona
L. Messi - Photo - Forward - 24/June/1987 - Argentina

what i need is to display is all players info in one row and put the current teams together like :
L. Messi - Photo - Forward - 24/June/1987 - FC Barcelona / Argentina
do i have to write another statement to display the current teams?

Viewing all articles
Browse latest Browse all 13329

Trending Articles