SQL Help please!

Associate
Joined
24 Sep 2005
Posts
209
I've spent the past while trying different ways to format this SQL query so that it works, but to no success...

Basically I want the php code to insert a row in a table (faults) and then to update the status of a computer in another table (computer).


So something like this:

$sql = "INSERT INTO Fault SET CompID='$CompID', Type='$Type', Description='$Description', StaffID='$StaffID', TechID='Unknown'";

Together with:

$sql = "UPDATE Workstation SET
Status='Attention'
WHERE CompID='$CompID'";

I have no idea how to combine these two queries... someone mentioned INNER JOIN but I cant get my head around that to any success either! Would anyone be able to point me in the right direction? Cheers
 
Mr^B said:
You have to do the queries one at a time, as there's an INSERT and then an UPDATE which you can't combine (no matter how many tables you join together).

so the first query will be the insert one.

INSERT INTO Fault VALUES($CompID, etcetc)

The next one will be the update.

UPDATE Workstation SET blah=x WHERE


How would I go about combining them in PHP though? At the mo, the SQL query is triggered by a Submit button from a form. I was going to separate them, but didnt realise you could have more than one SQL statement.
 
Back
Top Bottom