sir pannels
01-02-2007, 12:22 PM
Hi all,
Need a bit of help if you will :)
I have two tables, one of them (user_fleet) holds a couple of ID's aswell as a 'number'. The second table (fleet_allocation) holds the same ID's and a fleetId ...
I'm trying to get the 'number' of each fleet for set results...
For example im going to search on two ids as follows
uid = 1
vid = 3
There should be the following results for this ...
user_fleet has 1 row which holds the two id's and the overal number
user_fleet
uid vid number
1 3 100
fleet_allocation has 2 rows which hold the total number split between the rows ...
fleet_allocation
uid vid number fleetId
1 3 60 1
uid vid number fleetId
1 3 40 0
The query I have returns the following:
number fleetId
100 0
100 1
yet it should return:
number fleetId
40 0
60 1
The query I have is :
SELECT ic.number, t1.fleetId
FROM fleet_allocation AS t1
JOIN user_fleet AS ic ON t1.uid = ic.uid
AND t1.uid = ic.uid
AND t1.vid = ic.vid
WHERE ic.uid =1
AND ic.vid =3
Can anyone see what I have done wrong? If I have misunderstood JOIN please let me know.
Any help would be greatly apperciated.
Many thanks
Sir P :D
Need a bit of help if you will :)
I have two tables, one of them (user_fleet) holds a couple of ID's aswell as a 'number'. The second table (fleet_allocation) holds the same ID's and a fleetId ...
I'm trying to get the 'number' of each fleet for set results...
For example im going to search on two ids as follows
uid = 1
vid = 3
There should be the following results for this ...
user_fleet has 1 row which holds the two id's and the overal number
user_fleet
uid vid number
1 3 100
fleet_allocation has 2 rows which hold the total number split between the rows ...
fleet_allocation
uid vid number fleetId
1 3 60 1
uid vid number fleetId
1 3 40 0
The query I have returns the following:
number fleetId
100 0
100 1
yet it should return:
number fleetId
40 0
60 1
The query I have is :
SELECT ic.number, t1.fleetId
FROM fleet_allocation AS t1
JOIN user_fleet AS ic ON t1.uid = ic.uid
AND t1.uid = ic.uid
AND t1.vid = ic.vid
WHERE ic.uid =1
AND ic.vid =3
Can anyone see what I have done wrong? If I have misunderstood JOIN please let me know.
Any help would be greatly apperciated.
Many thanks
Sir P :D