A little bit of SQL help.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ianhull
Forum Contributor
Posts: 310
Joined: Tue Jun 14, 2005 10:04 am
Location: Hull England UK

A little bit of SQL help.

Post 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.
facets
Forum Contributor
Posts: 273
Joined: Wed Apr 13, 2005 1:53 am
Location: Detroit

Post by facets »

It will update just one as long as it meets both WHERE criteria.
ianhull
Forum Contributor
Posts: 310
Joined: Tue Jun 14, 2005 10:04 am
Location: Hull England UK

Post 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.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

UPDATE will change all rows that match the WHERE clause criteria (excluding ones that match the setting)
ianhull
Forum Contributor
Posts: 310
Joined: Tue Jun 14, 2005 10:04 am
Location: Hull England UK

Post by ianhull »

Thanks Feyd,

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

Much appreciated.....again. :D
facets
Forum Contributor
Posts: 273
Joined: Wed Apr 13, 2005 1:53 am
Location: Detroit

Post by facets »

My mistake, sorry ian.
ianhull
Forum Contributor
Posts: 310
Joined: Tue Jun 14, 2005 10:04 am
Location: Hull England UK

Post by ianhull »

Hey no problem,

Thanks for your help anyway.

:D
Post Reply