我应该执行这样的例子:
我们应该选择名为“Car”的所有文件。 如果没有“汽车”,我应该选择“摩托车”。
换句话说,它应该像这样工作: IF(名称='Car')然后smth与Car相关 否则如果(name ='Car'不存在)那么smth与Motorbike相关。
我们有多个表:一个表与上面的表相关。
A,B,C,......,车辆。
在查询中,我想这样做:
SELECT a.(some field), b.(some field), c.(some field), vehicle.(some field)
FROM a, b, c, ..., vehicle
WHERE
if vehicle = 'CAR' THEN a.(some field) = vehicle.(some field)
else if vehicle = 'CAR' does not exist, then a.(some field) = vehicle(MOTOR).(some field)
Table Vehicle (idV, idAll, nameVehicle, vehicleProductionDate):
1. 1, 1ABC, Car, 26-Apr-15
2. 2, 1ABC, Car, 26-Apr-16
3. 3, 1ABC, Car, 26-Apr-17
4. 4, 1ABC, Bike, 26-Apr-18
5. 5, 1ABC, Motorbike, 26-Apr-18
6. 6, 2ABC, Bike, 26-Apr-15
7. 7, 2ABC, Bike, 26-Apr-16
8. 8, 2ABC, Bike, 26-Apr-17
9. 9, 2ABC, Motorbike, 26-Apr-15
10. 10, 2ABC, Motorbike, 26-Apr-17
11. 11, 2ABC, Motorbike, 26-May-16
Table Step (idS, idAll, nameStep, logStepDate):
1. 1, 1ABC, Testing, 25-Apr-17
2. 2, 2ABC, Logging, 25-Apr-17
Table Company: (idC, idAll, nameCompany):
1. 1, 1ABC, Jeep
2. 2, 2ABC, Ford
And my final result, when executing, should contain all 3 tables data:
1, 1ABC, Jeep, Testing, 25-Apr-17, Car, 26-Apr-16
2, 2ABC, Ford, Logging, 25-Apr-17, Motorbike, 26-May-16
如果您看到,记录日期应等于或大于车辆生产日期,如果有多个 车辆< / em>哪些更少,那么我们应该采用最新的车辆。