Microsoft
Software
Hardware
Network
Question : MySQL update set Concatenate question
I have a MySQL query that globally updated f column is one table with a concatenation of column values and strings from another table. I seemed to have stumbled on the syntax that will update all of the rows:
UPDATE bookings_items SET desc_en = (SELECT CONCAT('#',prty_id,': ',property.prty_title) FROM property WHERE bookings_items.id_ref_exte
rnal = property.prty_id)
This sets the desc_en column to "#"+the property id from the property table + the property title from the property table WHERE the id_ref_external in bookings.items and prty_id in property are equal. Guess I need to change to:
UPDATE bookings_items SET desc_en = (SELECT CONCAT('#',property.prty_i
d,': ',property.prty_title) FROM property WHERE bookings_items.id_ref_exte
rnal = property.prty_id)
or
UPDATE bookings_items SET desc_en = (SELECT CONCAT('#',prty_id,': ',prty_title) FROM property WHERE bookings_items.id_ref_exte
rnal = property.prty_id)
This seems to work to change every row in the table and pull from the corresponding data in the property table.
What I'd like to do is make the same update for s specified row in the bookings_items table. i.e. only want to make the Change for those rows in bookings.items where id_ref_external is explicitly specified (e.g. $_POST[new_id])
Any help with that? Seems like the specific case would be easier than the global case.
Answer : MySQL update set Concatenate question
Syntax check:
$mysqlqry =
"UPDATE bookings_items SET desc_en = " .
"(SELECT CONCAT('#',prty_id,': ',property.prty_title) FROM property " .
"WHERE bookings_items.id_ref_exte
rnal = property.prty_id) " .
"WHERE id_ref_external = $_POST[new_id]";
Random Solutions
SBS 2008 move data feature crashes
SharePoint Designer Workflows have stopped sending emails
OCS 2007 R2 and Cisco call manager
DBGrid's content into email
error opening with internet explorer in MOSS 2007
VMware VirtualCenter Server Service will not stay Started on our vCenter box
Secondary namespace in WSDL
Are Mac's easier to support than PC's? Why or why not?
Unable to Search Empty Folders
Apple Mail - Find local Exchange email after changing accounts?