Page 1 of 1

A little bit of SQL help.

Posted: Sun Sep 18, 2005 8:00 am
by ianhull
Hi Guys,

Can any of you give me advice on how this SQL would work?
Would it update all the columns in the database where the companyname and coursetitle are?
or would it update just one?

Code: Select all

$status = "ONLINE";
$sql = "UPDATE courses SET status='$status' WHERE coursetitle='$_SESSION['coursetitle']' AND companyname='$_SESSION['companyname']' ";
Thanks in advance.

Posted: Sun Sep 18, 2005 8:12 am
by facets
It will update just one as long as it meets both WHERE criteria.

Posted: Sun Sep 18, 2005 8:15 am
by ianhull
Thanks,

Could you give me a hint on how to update all rows which match that criteria?
I think I will probaly have to use a loop or something but I don't really know how.


Thanks in advance.

Posted: Sun Sep 18, 2005 8:19 am
by feyd
UPDATE will change all rows that match the WHERE clause criteria (excluding ones that match the setting)

Posted: Sun Sep 18, 2005 8:21 am
by ianhull
Thanks Feyd,

I will have a go at using what I alread have.

Much appreciated.....again. :D

Posted: Sun Sep 18, 2005 8:24 am
by facets
My mistake, sorry ian.

Posted: Sun Sep 18, 2005 8:34 am
by ianhull
Hey no problem,

Thanks for your help anyway.

:D