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
Active Directory queries to pull distribution list members and user email addresses
Dates Don't show up when Output to Excel
connect an iPhone to Windows SBS 2003
Thumb Drive -- file transfer fails ?
OWA Setup
Crystal in Visual Studio dynamic Database persistant on postback
workgroup computer connected to domain LAN cannot browse web but can resolve IPs
Keystore file to sign jar via a thawte code signing certificate
Can't Remote Desktop to Forefront TMG Server
call .rdl with store procedure with parameter