Page 1 of 1

update 1 table by comparing 2 tables

Posted: Sat Jan 31, 2009 3:08 am
by knightsjoker
Hi guys,

I'm stump on how to do this. Basically I'm trying to update 1 table by comparing values from different tables.

here's how i set it up:

Code: Select all

 
$query = "SELECT booking_event.starting_date_time, booking_schedule.schedule_date_time ".
 "FROM booking_event, booking_schedule ".
    "WHERE booking_event.starting_date_time = booking_schedule.schedule_date_time";
 
with that part set...
i want to update a different field which is event_id_location_# (there are 20 locations)
I want to update just certain location according to the schedule_date_time

so let's say location 1 has a value of 1 (occupied) I want to update it to 0 (not occupied)

how do I go about doing this? I already passed the hidden value of location (is it correct?):

Code: Select all

 
<a href=\"delete.php?id={$row[id]}&passlocation={$getlocation}\">Delete</a>"; ?>
 
I was thinking of if function.

Code: Select all

 
while($row = mysql_fetch_array($query))
{
    if (location == loc1)
    {
        query2="UPDATE booking_schedule SET event_id_location_1 = '0'";
    }
}
 
thanks guys