Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

Coding Forum


You are currently viewing our Coding Forum as a guest. Please register to participate.
Login



Closed Thread
Old 06-28-2002, 06:07 PM Mysql update syntax
Skilled Talker

Posts: 60
Location: Grand Rapids
Trades: 0
I want to know if this syntax is correct before I try anything. I have a field with info in it all ready and I want to add a string to every entree. Is this correct syntax. if not what is. I couldn't find it in the docs.

update table set field = field + 'this is the string';


anyone??
__________________

Please login or register to view this content. Registration is FREE
- PHP PhotoGallery
redcircle is offline
View Public Profile
 
 
Register now for full access!
Old 06-28-2002, 06:47 PM
Skilled Talker

Posts: 66
Location: British Columbia, Canada
Trades: 0
I haven'y used MySQL before but it looks like you are
missing a WHERE clause

so:

update table set field = field + 'this is the string' WHERE field2 = 'value_here';
wynpublishing is offline
View Public Profile
 
Old 06-29-2002, 03:27 AM
AhmedF's Avatar
Left for Better Places

Posts: 258
Trades: 0
UPDATE {tableName} SET <col>=NewColValue WHERE <WHERE CLAUSE>

So, for example:

UPDATE articles SET totalNumb = 5 WHERE ID = 4;

www.php.net/manual
Read the user comments etc.
AhmedF is offline
View Public Profile
 
Old 06-29-2002, 01:50 PM
Skilled Talker

Posts: 60
Location: Grand Rapids
Trades: 0
Quote:
I haven'y used MySQL before but it looks like you are
missing a WHERE clause

You only need a where clause if you want to change one specific entree. I wanted to add a string to every one in the table so a where clause is not needed.

Quote:
UPDATE {tableName} SET <col>=NewColValue WHERE <WHERE CLAUSE>

So, for example:

UPDATE articles SET totalNumb = 5 WHERE ID = 4;
That is just for updating not adding 2 strings together in an update. here is what I found so if anyone else needs it, it will not be hard to find.

update table set field = concat(field,'string',...etc); And if you need a specific entree you can add the where clause.

Thanks guys for trying.
__________________

Please login or register to view this content. Registration is FREE
- PHP PhotoGallery
redcircle is offline
View Public Profile
 
Old 08-19-2002, 11:35 AM
Average Talker

Posts: 15
Trades: 0
I would suggest that you use following script :

$field1 = $field."this is the string";

update table set field = '$field1';

This will update all rows that met the criteria. To update specific rows, add in WHERE clause
programmingguru is offline
View Public Profile
 
Closed Thread     « Reply to Mysql update syntax
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.15451 seconds with 12 queries