Soldato
- Joined
- 5 May 2004
- Posts
- 4,462
- Location
- Northern Ireland
Hello
I need a little help with my sql query.
I have two tables one being longer than the other and I would like where the driverNo1 - 6 are in Table 1 and are the drivers of person Peter get the race1session1 number
This is my query so far but for some reason it returns everything. I have tried different variations of it and in one case it pulled back 6 copies of each driver
These are my tables:
Table 1
Table 2
Any help in this matter is appericated. This is not for school/college/uni work.
Thanks,
Peter
I need a little help with my sql query.
I have two tables one being longer than the other and I would like where the driverNo1 - 6 are in Table 1 and are the drivers of person Peter get the race1session1 number
This is my query so far but for some reason it returns everything. I have tried different variations of it and in one case it pulled back 6 copies of each driver
Code:
select driverName from Table1, selection where driverName = selection.driverNo1 or selection.driverNo2 and playerName = 'Peter'
These are my tables:
Table 1
Code:
driverName race1session1
Sebastian Vettel 1
Mark Weber 2
Lewis Hamilton 3
Jenson Button 4
Fernando Alonso 5
Felipe Massa 6
Michael Sch 7
Nico Rosberg 8
Robert Kubica 9
Vitaly Petrov 10
Rubens Barrichello 11
Table 2
Code:
playerName driverNo1 driverNo2 driverNo3 driverNo4 driverNo5 driverNo6
Peter Fernando Alonso Segio Perez Jaime Alguersuari Heikki Kovalainen Jarno Trulli Rubens Barrichello
Brian Sebastian Vettel Narain Karthikeyan Jarno Trulli Jenson Button Kamui Kobayashi Segio Perez
Keith Sebastien Buemi Jarno Trulli Jaime Alguersuari Kamui Kobayashi Heikki Kovalainen Narain Karthikeyan
Paul Jenson Button Sebastien Buemi Jarno Trulli Jaime Alguersuari Heikki Kovalainen Narain Karthikeyan
Aaron Rubens Barrichello Paul di Resta Sebastien Buemi Jaime Alguersuari Heikki Kovalainen Narain Karthikeyan
Dave Narain Karthikeyan Heikki Kovalainen Jerome d'Ambrosio Timo Glock Jarno Trulli Jaime Alguersuari
Any help in this matter is appericated. This is not for school/college/uni work.
Thanks,
Peter
Last edited: