0

Am trying to only concat new updates to column updates and UPDATE the values in the rest of the columns but I've hit bit of a snag that I can't seem to workout.

My SQL looks like this:

$query="Update tickets SET product='$product',
        p='$p',
        i='$i',
        summary='$summary',
        workaround='$workaround',
        concat(updates,'$additional_update'),
        status='$status',
        raised_by='$raised_by',
        updated_by_user='$updated_by' WHERE id='$id'";

the updates column is like a comments column, where new updates are meant to be appended to the existing text.

The error I'm getting on the web server:

Update tickets SET product='T-Box', p='00000817766', i='-', summary='Testing update field
\r\nAdding an update\r\ntesting if null works for update', workaround='n/a', concat(updates,' ','test2@18:53:17:second update/n'), status='Open', raised_by='No', updated_by_user='test2' WHERE id='223'

Running the query directly in MySQL:

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(updates,'test2@18:53:17:second update/n'), status='Open', raised_by='No', updat' at line 1

Help is much appreciated!

2 Answers 2

2

You need to specify where the value of this statement concat(updates,'$additional_update') to be set.

Update tickets 
SET    product = '$product',
       p = '$p',
       i = '$i',
       summary = '$summary',
       workaround = '$workaround',
       updates = CONCAT(updates,'$additional_update'),  // <== see this
       status = '$status',
       raised_by = '$raised_by',
       updated_by_user = '$updated_by' 
WHERE id = '$id'
Sign up to request clarification or add additional context in comments.

1 Comment

I just needed the updates = CONCAT(updates,'$additional_update'), line to fix it!
0

try this:

$query="Update tickets SET product='$product',
        p='$p',
        i='$i',
        summary='$summary',
        workaround='$workaround',
        updates=concat(updates,'$additional_update'),
        status='$status',
        raised_by='$raised_by',
        updated_by_user='$updated_by' WHERE id='$id'";

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.