Re: [PHP-DB] HELP With UPDATE Query in mySQL
and put it inside a transaction cos in case something goes wrong part of the way through pete Jeff Shapiro wrote: This should do it: UPDATE Bookings SET Booking_Start_Date = CONCAT(DATE_FORMAT(Booking_Start_Date, '%Y-%m-%d'), '09:00:00'), Booking_End_Date = CONCAT(DATE_FORMAT(Booking_End_Date, '%Y-%m-%d'), '17:30:00'); If you are using version 4.1.1 or newer the DATE_FORMAT function could be replaced by: DATE(Booking_Start_Date) On Fri, 3 Oct 2003 22:54:49 +0100, Shaun spoke thusly about [PHP-DB] HELP With UPDATE Query in mySQL: Hi, I have two columns in my Bookings table of type DATETIME - Booking_Start_Date and Boking_End_Date. How can i update every row so that all of the times for Booking_Start_Date are 09.00 and all of the times for Booking_End_Date are 17.30, without affecting any of the dates? Thanks for your help --- Listserv only address. Jeff Shapiro -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] HELP With UPDATE Query in mySQL
This should do it: UPDATE Bookings SET Booking_Start_Date = CONCAT(DATE_FORMAT(Booking_Start_Date, '%Y-%m-%d'), '09:00:00'), Booking_End_Date = CONCAT(DATE_FORMAT(Booking_End_Date, '%Y-%m-%d'), '17:30:00'); If you are using version 4.1.1 or newer the DATE_FORMAT function could be replaced by: DATE(Booking_Start_Date) On Fri, 3 Oct 2003 22:54:49 +0100, Shaun spoke thusly about [PHP-DB] HELP With UPDATE Query in mySQL: > Hi, > > I have two columns in my Bookings table of type DATETIME - > Booking_Start_Date and Boking_End_Date. How can i update every row so that > all of the times for Booking_Start_Date are 09.00 and all of the times for > Booking_End_Date are 17.30, without affecting any of the dates? > > Thanks for your help --- Listserv only address. Jeff Shapiro -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] HELP With UPDATE Query in mySQL
Hi, I have two columns in my Bookings table of type DATETIME - Booking_Start_Date and Boking_End_Date. How can i update every row so that all of the times for Booking_Start_Date are 09.00 and all of the times for Booking_End_Date are 17.30, without affecting any of the dates? Thanks for your help -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Help with UPDATE query
Hi, I have two columns in my Bookings table of type DATETIME - Booking_Start_Date and Boking_End_Date. How can i update every row so that all of the times for Booking_Start_Date are 09.00 and all of the times for Booking_End_Date are 17.30, without affecting any of the dates? Thanks for your help -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Help with update...
it's amazing.. I've been banging my head for over an hour on this, then as soon as I send for help, I see the obvious - first of all, my error checking was done *before* the query executed... then, to make it even more of an effort in mindlessness, the table name capitalization was throwing it all off!! Sorry for the waste of good bandwidth... ~BD~ http://www.bustdustr.net http://www.rfbdproductions.com Home Of Radio Free BD For The Difference. - Original Message - From: BD <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Saturday, August 18, 2001 12:21 PM Subject: [PHP-DB] Help with update... > I'm working under the gun here, so please excuse me if this turns out to be > something really simple, but it's got me stumped... I'm trying to update the > "cover" field in a table by using the album_id field in the table and adding > a ".jpg" extention to it... > For example: > "Update albums set cover = "1.jpg" where album_id = 1" > > For some reason, however, the update isn't working when executed... here are > the results I get: > > album_id: 1 - cover: 1.jpg > UPDATE ALBUMS SET COVER = "1.jpg" WHERE ALBUM_ID = 1 > mysql_errno: 0: mysql_error: > Update Failed! > > As you can see, there's no error code generated, and the update statement > works great from the command line... > > here's the relevant code (i'm connecting to the database as root, so i don't > think it's a permissions thing...): > $query = "SELECT * FROM albums ORDER BY album_id"; > > $stuff = mysql_query($query) or die("Select Failed!"); > > while ($results = mysql_fetch_array($stuff)) { > > $cover = $results['album_id'].".jpg"; > $album_id = $results['album_id']; > echo $album_id." - ".$cover.""; > $update = "UPDATE ALBUMS SET COVER = \"$cover\" WHERE ALBUM_ID = > $album_id"; > echo $update.""; > echo mysql_errno().": ".mysql_error().""; > mysql_query($update) or die("Update Failed!"); > } > > > Simple... right? But it's beating me up this morning.. I would greatly > appreciate it if anyone could show me the error of my ways... > > ~BD~ > > http://www.bustdustr.net > http://www.rfbdproductions.com > Home Of Radio Free BD > For The Difference. > > > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] Help with update...
I'm working under the gun here, so please excuse me if this turns out to be something really simple, but it's got me stumped... I'm trying to update the "cover" field in a table by using the album_id field in the table and adding a ".jpg" extention to it... For example: "Update albums set cover = "1.jpg" where album_id = 1" For some reason, however, the update isn't working when executed... here are the results I get: album_id: 1 - cover: 1.jpg UPDATE ALBUMS SET COVER = "1.jpg" WHERE ALBUM_ID = 1 mysql_errno: 0: mysql_error: Update Failed! As you can see, there's no error code generated, and the update statement works great from the command line... here's the relevant code (i'm connecting to the database as root, so i don't think it's a permissions thing...): $query = "SELECT * FROM albums ORDER BY album_id"; $stuff = mysql_query($query) or die("Select Failed!"); while ($results = mysql_fetch_array($stuff)) { $cover = $results['album_id'].".jpg"; $album_id = $results['album_id']; echo $album_id." - ".$cover.""; $update = "UPDATE ALBUMS SET COVER = \"$cover\" WHERE ALBUM_ID = $album_id"; echo $update.""; echo mysql_errno().": ".mysql_error().""; mysql_query($update) or die("Update Failed!"); } Simple... right? But it's beating me up this morning.. I would greatly appreciate it if anyone could show me the error of my ways... ~BD~ http://www.bustdustr.net http://www.rfbdproductions.com Home Of Radio Free BD For The Difference. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]