
04-21-05, 06:20 AM
|
|
Newbie Coder
|
|
Join Date: Feb 2005
Posts: 64
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
|
joins????
hi i have a little join problem i think:
i have a table: cars [carno,teamname,factory,engine]
another table called: Drivers[driverno,fullname,carno,age,nationality]
I want to list all team names whose drivers have a specific nationality.
i currently use a search method were i use a form(uses GET) and a seachstring. I use a URL varialbe called SearchString and then Do a record set for the results.
can anyone help me with this?
thanks in advance
g
|

04-21-05, 06:45 AM
|
|
Newbie Coder
|
|
Join Date: Feb 2005
Posts: 64
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
|
the code im trying
this is the code im trying but it dont seem to work??
any help would be great thanks
g
|

04-21-05, 06:46 AM
|
|
Code Guru
|
|
Join Date: Oct 2004
Location: UK
Posts: 801
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
you dont have the same field in both tables such as a primary key so you cant do it!
__________________
Alexa Share <-- Trade virtual shares in websites with this online game.
codR.us <-- Submit and vote for your favorite code snippets with codR.us.
XEWeb.net <-- The ultimate PHP resource network.
|

04-21-05, 06:48 AM
|
 |
Community VIP
|
|
Join Date: Aug 2003
Location: K.S.A
Posts: 2,257
Thanks: 0
Thanked 2 Times in 1 Post
|
|
try this one..
or you could use a normal join..
__________________
PHPSimplicity
We don't need a reason to help people - Zidane [FF9]
Last edited by NeverMind; 04-21-05 at 06:54 AM.
|

04-21-05, 07:08 AM
|
|
Newbie Coder
|
|
Join Date: Feb 2005
Posts: 64
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
|
thanks for that
cheers mate that worked a treat.
two more thing, if you can help
1) i want to allow the user to search for a car were the factory date is within a user specified range?
will i have to have two text boxes, and ask them to enter two date ie, 03/03/05 and 04/04/06?
how do i do a search with these two strings?
or am i going about it in the wrong way?
2)the average thing i was trying to do, i need to join three tables i think, i need the average age of the drivers and mechanics for a specified team. so thats the driver, mechanic and car tables. any ideas?
thanks again.
g
|

04-21-05, 07:17 AM
|
 |
Community VIP
|
|
Join Date: Aug 2003
Location: K.S.A
Posts: 2,257
Thanks: 0
Thanked 2 Times in 1 Post
|
|
Quote:
1) i want to allow the user to search for a car were the factory date is within a user specified range?
will i have to have two text boxes, and ask them to enter two date ie, 03/03/05 and 04/04/06?
how do i do a search with these two strings?
|
what is the type of the date field you have in your database?
Quote:
|
2)the average thing i was trying to do, i need to join three tables i think, i need the average age of the drivers and mechanics for a specified team. so thats the driver, mechanic and car tables. any ideas?
|
you mean you want to get the average of car drivers age by nationality?
this could be done with the same query you used from above, just add the following after SELECT:
and at the end put:
so it would be:
I didn't quit understand the mechanics part! what does the third table has in it?
__________________
PHPSimplicity
We don't need a reason to help people - Zidane [FF9]
|

04-21-05, 07:25 AM
|
|
Newbie Coder
|
|
Join Date: Feb 2005
Posts: 64
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
|
hi ill try and be a little clearer
what is the type of the date field you have in your database?
= its in an sql database as type 'date'
you mean you want to get the average of car drivers age by nationality?
= no, sorry i got that wrong, i want to list the average age of all personal who work for a user specified teamname.
table are: cars[carno,teamname,factorydate,make,sponsor]
drivers[fullname,carno,age,nationality,points]
mechanics[fullname,carno,age,nationality,skill,position]
hope that clears up what im trying to do
thanks for the help
g
|

04-21-05, 07:41 AM
|
|
Newbie Coder
|
|
Join Date: Feb 2005
Posts: 64
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
|
iv come up with something like this
this is what i have at the min:
[ thanks agian
Last edited by godonholiday; 04-21-05 at 08:07 AM.
|

04-22-05, 05:49 AM
|
 |
Community VIP
|
|
Join Date: Aug 2003
Location: K.S.A
Posts: 2,257
Thanks: 0
Thanked 2 Times in 1 Post
|
|
don't use LIKE when you know the exact value of the teamname (or whatever field)
as for date comparision..
you could use:
this will fetch everything from "cars" table between the dates 2005-04-22 and 2005-04-25
I assumed the field date's type as DATE (format YYYY-MM-DD)
the user input should be in format YYYY-MM-DD
__________________
PHPSimplicity
We don't need a reason to help people - Zidane [FF9]
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|