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
Conditional Formating in Access
Blackberry browser 400 error - socketexception Connection reset
Best way to handle vanity urls in IIS?
-ERR Protocol Error. 17
Splitting db and performance
The 5000n printer will only print to the manual feed tray
basic quadratic question
Change LDAP log level on Snow Leopard
How do I resolve this error "javax.xml.ws.WebServiceEx
ception .... Place the resource correctly in the classpath.?
Outlook 2007 duplicate contacts created when importing from .csv