473,379 Members | 1,270 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

Quickly adding text to a mysql text field that is NOT empty

Hi all

Is there a way to insert text into a mysql text field that already has
text into it; without having first to extract the existing data and
append the new text to that string variable and then insert the new
string.

Basically i'm looking for a way to do it with a single query not 2 (one
being a select to gather existing data).

Please help!

Feb 5 '06 #1
6 38203
I could have sworn I already replied to this but it appears that it did
not go through, but anyway; you want to modify the contents of an
existing field without having to fetch it using a query, yes? This is
possible through the use of MySQL's CONCAT() function:

UPDATE `my_table` SET `my_field` = CONACT(`my_field`, ' append this');

So, for example the value of 'my_field' is 'John'. Upon running the
query the value of 'my_field' will become 'John append this'. Hope that
helps.

Feb 5 '06 #2
So basically you want to append a string or data to existing data in a
field without having to fetch the contents of that field first? Yeah,
that's possible:

UPDATE `my_table` SET `myfield` = CONCAT(`myfield`, 'newvalue');

So say the value of 'myfield' was 'John' and I ran that query, the
value of 'myfield would now be 'Johnnewvalue'. Is that what you wanted?

Feb 5 '06 #3
So say the value of 'myfield' was 'John' and I ran that query, the
value of 'myfield would now be 'Johnnewvalue'. Is that what you wanted?


Thanks for your help xcla, the problem I have is that I don't know what
is in the first part of the string, so i need a query which adds to the
data that is in there without me defining it.

Feb 5 '06 #4
Yeah I've got it working now thanks!

Feb 5 '06 #5
You're very welcome, I used 'John' as an example, just specifying the
field name works as I assume you've already found out. Glad I could
help!

Feb 5 '06 #6

<xc*****@gmail.com> wrote in message
news:11*********************@o13g2000cwo.googlegro ups.com...
I could have sworn I already replied to this but it appears that it did
not go through, but anyway; you want to modify the contents of an
existing field without having to fetch it using a query, yes? This is
possible through the use of MySQL's CONCAT() function:

UPDATE `my_table` SET `my_field` = CONACT(`my_field`, ' append this');
you mean CONCAT

So, for example the value of 'my_field' is 'John'. Upon running the
query the value of 'my_field' will become 'John append this'. Hope that
helps.

Feb 12 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Noyb | last post by:
How do I convert a string into a value I can upload to mysql date field. Specifically, I have a user select a month, day and year from drop-downs, then I want them submitted to one date field....
6
by: LRW | last post by:
I have an automated process which uploads a comma separated spreadsheet (csv) and inserts it into a database: $sql = "LOAD DATA INFILE '".$uploadfile."' INTO TABLE `tbl_tracking` FIELDS...
4
by: phpuser32423 | last post by:
Hi all I have been searching for hours on the php website for a function that will allow me to display just the first 50 chars of a mysql text field in a results table, but i'm having no luck. I...
1
by: Gabriël | last post by:
Hi All, I've created an eventhandler for ItemdataBound and ItemCreated, but when I access "e.Item.Cells.Text" it's always empty. BUT, when I assign a value to this empty field (while being in...
4
by: David Plotts | last post by:
I'm a beginner with VB.net, only had one class in college on it. I can't seem to remember how to add text boxes up. I want to add the values in text boxes together, and put the value into a...
4
by: shihab | last post by:
I have one multi line text box.i want to 'add text this text box one by one' from database(eg.Customer Name Field).i am using C#.plz give me a solution thanx shihab
1
by: kunalm | last post by:
Hello I am trying to insert and then read some text from a textarea control, into a mysql TEXT field, with php. For that I am using simple php code for insertion of records. But the...
8
by: elastreto | last post by:
Hello, I have been trying, so far in vain, to hide the label and text control in a form when the text control is empty/null. I have looked at past postings and tried the code below, however I...
18
by: Academia | last post by:
I let the use modify the text of a combobox and then I replace the selected item with the new text (in Keyup event). But if he sets the Text property to an empty string ("") that sets the...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.