0

I develop a web based cab reservation system. I have a table called vehicle and cab_reservation table in mysql database. So i want to select one vehicle from vehicle table and pass it to cab_reservation table when user booking a cab. In Vehicle table primary key is vehicle number.

TimWolla
  • 31,849
  • 8
  • 63
  • 96
Anushka Deshan
  • 81
  • 4
  • 14
  • 1
    Maybe you can look at the concept of `relations` as explained here: http://stackoverflow.com/questions/260441/how-to-create-relationships-in-mysql Otherwise, a more precise question would be welcome: what do you mean by "pass it to". If you're using PHP, you could easily get the vehicle_id (I presume) and add it into your next MySQL query... – achedeuzot Feb 02 '14 at 17:32

1 Answers1

0

It depends on the language you want to use. But as we have only information that you are using MySQL, you can use something like this

INSERT INTO cab_reservation (vehicle_number, other_columns, ... )
SELECT  v.vehicle_number, ...
FROM    vehicle v
WHERE   v.vehicle_number = ...;

I suppose cab_reservation has some sort of id as primary key and additional data.

Michal Brašna
  • 2,293
  • 13
  • 17