Hi all, can someone help me with my query please? I have done some searching and can't seem to find an answer to my query problem. I need a query that will delete one vehicle(v_id) AND all service(s_id) records associated with the vehicle. The problem is that my existing query only works when there is one or more than one service record associated with the vehicle deleted...it will not work if there is one vehicle and no service records.
Here is my query:
DELETE vehicles, service FROM vehicles, service WHERE vehicles.v_id = ".$delete_vehicle." AND service.v_id = ".$delete_vehicle."
I am using PHP if that helps out with the solution.
I have two tables - the relationship is one vehicle(v_id) to none, one, or more than one service record(s_id):
service
------------
[s_id](index)
v_id
s_type
s_date
-----------
and
vehicles
------------
[v_id](index)
v_make
v_model
I hope I explained everything, but please post if you have questions - thanks in advance!
MikeWire
Here is my query:
DELETE vehicles, service FROM vehicles, service WHERE vehicles.v_id = ".$delete_vehicle." AND service.v_id = ".$delete_vehicle."
I am using PHP if that helps out with the solution.
I have two tables - the relationship is one vehicle(v_id) to none, one, or more than one service record(s_id):
service
------------
[s_id](index)
v_id
s_type
s_date
-----------
and
vehicles
------------
[v_id](index)
v_make
v_model
I hope I explained everything, but please post if you have questions - thanks in advance!
MikeWire