Re: [PHP-DB] UPDATE query

2011-03-19 Thread Omega -1911
On Tue, Mar 8, 2011 at 11:16 AM, Ron Piggott
 wrote:
>
> I am wondering if there is a way to do an UPDATE query where only some of the 
> text changes.
>
> The column I need to modify is named “toll_free”
> What I need to search for is: 800-
> I need it to replace it with is 1-800-
> - BUT I don’t want to change instances of 1-800-
> - I need to leave the rest of the toll free phone number in tact.
>

Another example::
-
update TABLE_NAME set FIELD_NAME = replace(FIELD_NAME, ‘find this
string’, ‘replace found string with this string’);

update client_table set company_name = replace(company_name, ‘Old
Company’, ‘New Company’)

The above statement will replace all instances of ‘Old Company’ to
‘New Company’ in the field of company_name of client_table table.

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] UPDATE query

2011-03-08 Thread Ron Piggott

I found a way to do this Bastien:

UPDATE `database`.`table` SET `toll_free` = CONCAT( '1-', `toll_free` ) 
WHERE `toll_free` LIKE '866-%'


Ron

The Verse of the Day
“Encouragement from God’s Word”
http://www.TheVerseOfTheDay.info

-Original Message- 
From: Bastien Koert

Sent: Tuesday, March 08, 2011 11:20 AM
To: Ron Piggott
Cc: php-db@lists.php.net
Subject: Re: [PHP-DB] UPDATE query

On Tue, Mar 8, 2011 at 11:16 AM, Ron Piggott
 wrote:


I am wondering if there is a way to do an UPDATE query where only some of 
the text changes.


The column I need to modify is named “toll_free”
What I need to search for is: 800-
I need it to replace it with is 1-800-
- BUT I don’t want to change instances of 1-800-
- I need to leave the rest of the toll free phone number in tact.

Ron


The Verse of the Day
“Encouragement from God’s Word”
http://www.TheVerseOfTheDay.info



Ron,

I would strongly suggest that you be consistent in the data. Pick one
version (1-800 or 800-) and stick with it. Its a simple matter to do a
one time replace on that field to make them all consistent and from
there on your programming logic for the update you want to run is then
made much simpler.

You can do an update with a LIKE but it may update more than what you want 
to


update table set toll_free = '$some_value' where toll_free like 
'%800-###-'


--

Bastien

Cat, the other other white meat 



--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] UPDATE query

2011-03-08 Thread Ron Piggott


I was wondering this Bastien.  Ron

The Verse of the Day
“Encouragement from God’s Word”
http://www.TheVerseOfTheDay.info

-Original Message- 
From: Bastien Koert

Sent: Tuesday, March 08, 2011 11:20 AM
To: Ron Piggott
Cc: php-db@lists.php.net
Subject: Re: [PHP-DB] UPDATE query

On Tue, Mar 8, 2011 at 11:16 AM, Ron Piggott
 wrote:


I am wondering if there is a way to do an UPDATE query where only some of 
the text changes.


The column I need to modify is named “toll_free”
What I need to search for is: 800-
I need it to replace it with is 1-800-
- BUT I don’t want to change instances of 1-800-
- I need to leave the rest of the toll free phone number in tact.

Ron


The Verse of the Day
“Encouragement from God’s Word”
http://www.TheVerseOfTheDay.info



Ron,

I would strongly suggest that you be consistent in the data. Pick one
version (1-800 or 800-) and stick with it. Its a simple matter to do a
one time replace on that field to make them all consistent and from
there on your programming logic for the update you want to run is then
made much simpler.

You can do an update with a LIKE but it may update more than what you want 
to


update table set toll_free = '$some_value' where toll_free like 
'%800-###-'


--

Bastien

Cat, the other other white meat 



--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] UPDATE query

2011-03-08 Thread Bastien Koert
On Tue, Mar 8, 2011 at 11:16 AM, Ron Piggott
 wrote:
>
> I am wondering if there is a way to do an UPDATE query where only some of the 
> text changes.
>
> The column I need to modify is named “toll_free”
> What I need to search for is: 800-
> I need it to replace it with is 1-800-
> - BUT I don’t want to change instances of 1-800-
> - I need to leave the rest of the toll free phone number in tact.
>
> Ron
>
>
> The Verse of the Day
> “Encouragement from God’s Word”
> http://www.TheVerseOfTheDay.info
>

Ron,

I would strongly suggest that you be consistent in the data. Pick one
version (1-800 or 800-) and stick with it. Its a simple matter to do a
one time replace on that field to make them all consistent and from
there on your programming logic for the update you want to run is then
made much simpler.

You can do an update with a LIKE but it may update more than what you want to

update table set toll_free = '$some_value' where toll_free like '%800-###-'

-- 

Bastien

Cat, the other other white meat

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP-DB] Update Query

2003-10-29 Thread Hutchins, Richard
Aaron,

I'll tell you right now that I don't have ANY experience creating temporary
tables. None. Haven't needed to go down that road yet.

So, in the true spirit of the learning process, I'm going to do what anybody
else would (and should) do:

Take a wild guess. And here it is:

I think your process for creating your temporary table is flawed. I've
looked through the MySQL manual and found this:

"6.5.3 CREATE TABLE Syntax
CREATE [TEMPORARY] TABLE [IF NOT EXISTS] tbl_name [(create_definition,...)]
[table_options] [select_statement]"

So, without a really good understanding of what you're trying to select into
the temporary table, your query might look like:

CREATE TEMPORARY TABLE $tbl_temp SELECT distinct(company_id) from
Associations where product_id=9;

Then you can do whatever query you need to against the temporary table then,
when you're done, you'll drop the temporary table.

Your MySQL error is probably occurring because there is no table on which to
perform the query you're sending to the database.

I'm positive there are others on this list with more experience using
temporary tables than I, but this might be a push in the right direction (I
hope).

Hope this helps.

Rich

> -Original Message-
> From: Aaron Bryer [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, October 29, 2003 3:18 PM
> To: [EMAIL PROTECTED]
> Subject: RE: [PHP-DB] Update Query
> 
> 
> I did that below is the exact excerpt from the source of the 
> web browser
> 
> 
> 
> The My Sql Error is
> 
> Query failed : You have an error in your SQL syntax near '' at line 1
> 
> I have tried entering () around the select statement but that 
> seamed to make
> more errors
> 
> Thanks
> 
> Aaron
> 
> -Original Message-
> From: Hutchins, Richard [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, October 29, 2003 3:07 PM
> To: '[EMAIL PROTECTED]'; [EMAIL PROTECTED]
> Subject: RE: [PHP-DB] Update Query
> 
> 
> How do you know it failed? What is the mysql_error() returning to you?
> 
> I'd also recommend you echo out the query to the browser window before
> sending it so you can see exactly what's being sent to the 
> database. That'll
> help you troubleshoot SQL problems on your own.
> 
> > -Original Message-
> > From: Aaron Bryer [mailto:[EMAIL PROTECTED]
> > Sent: Wednesday, October 29, 2003 3:02 PM
> > To: [EMAIL PROTECTED]
> > Subject: [PHP-DB] Update Query
> >
> >
> >
> > Hello, I ma new to the list and looking for some help with
> > the following
> > query.
> >
> > insert into Temp (CompId) SELECT distinct(company_id) from
> > Associations
> > where product_id=9;
> >
> > When I exe that statement directly on the mysql command line
> > It exe's with
> > no problem. However when I
> > exe that through php $result = mysql_query($query) or
> > die("Query failed : "
> > . mysql_error()); it fails every time.
> >
> > Any Ideas?
> >
> > Using MYSQL 3.23.54
> > PHP 4.1.2
> >
> >
> > Thanks
> >
> > Aaron
> >
> > --
> > PHP Database Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
> 
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> -- 
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP-DB] Update Query

2003-10-29 Thread Aaron Bryer
I did that below is the exact excerpt from the source of the web browser



The My Sql Error is

Query failed : You have an error in your SQL syntax near '' at line 1

I have tried entering () around the select statement but that seamed to make
more errors

Thanks

Aaron

-Original Message-
From: Hutchins, Richard [mailto:[EMAIL PROTECTED]
Sent: Wednesday, October 29, 2003 3:07 PM
To: '[EMAIL PROTECTED]'; [EMAIL PROTECTED]
Subject: RE: [PHP-DB] Update Query


How do you know it failed? What is the mysql_error() returning to you?

I'd also recommend you echo out the query to the browser window before
sending it so you can see exactly what's being sent to the database. That'll
help you troubleshoot SQL problems on your own.

> -Original Message-
> From: Aaron Bryer [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, October 29, 2003 3:02 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP-DB] Update Query
>
>
>
> Hello, I ma new to the list and looking for some help with
> the following
> query.
>
> insert into Temp (CompId) SELECT distinct(company_id) from
> Associations
> where product_id=9;
>
> When I exe that statement directly on the mysql command line
> It exe's with
> no problem. However when I
> exe that through php $result = mysql_query($query) or
> die("Query failed : "
> . mysql_error()); it fails every time.
>
> Any Ideas?
>
> Using MYSQL 3.23.54
> PHP 4.1.2
>
>
> Thanks
>
> Aaron
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP-DB] Update Query

2003-10-29 Thread Hutchins, Richard
How do you know it failed? What is the mysql_error() returning to you?

I'd also recommend you echo out the query to the browser window before
sending it so you can see exactly what's being sent to the database. That'll
help you troubleshoot SQL problems on your own.

> -Original Message-
> From: Aaron Bryer [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, October 29, 2003 3:02 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP-DB] Update Query
> 
> 
> 
> Hello, I ma new to the list and looking for some help with 
> the following
> query.
> 
> insert into Temp (CompId) SELECT distinct(company_id) from 
> Associations
> where product_id=9;
> 
> When I exe that statement directly on the mysql command line 
> It exe's with
> no problem. However when I
> exe that through php $result = mysql_query($query) or 
> die("Query failed : "
> . mysql_error()); it fails every time.
> 
> Any Ideas?
> 
> Using MYSQL 3.23.54
> PHP 4.1.2
> 
> 
> Thanks
> 
> Aaron
> 
> -- 
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: Re: [PHP-DB] UPDATE query

2003-07-14 Thread CPT John W. Holmes
Can someone please unsubscribe/boot the ydnarb.com address below? Every time
I send a message to the list I receive a blank reply from the address. I
assume this is happening for others, also.

---John Holmes...

- Original Message - 
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, July 14, 2003 2:32 PM
Subject: Re: Re: [PHP-DB] UPDATE query


>
>
>


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] UPDATE query

2003-07-14 Thread CPT John W. Holmes
> $query1 = "UPDATE news,autori SET
> news.titolo='$titolo', news.testo='$testo',
> news.data='$data', news.nome='$nome',
> autori.mail='$mail' WHERE news.nome =
> autori.nome AND id='$id'";

You can't do an update across tables the last time I checked. Even if it's
possible in newer versions, using mysql_error() after your query will tell
you what the error is.

---John Holmes...


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP-DB] Update Query Help...

2002-12-11 Thread Ford, Mike [LSS]
> -Original Message-
> From: NIPP, SCOTT V (SBCSI) [mailto:[EMAIL PROTECTED]]
> Sent: 10 December 2002 20:02
> 
>   I have definitely isolated the problem.  If I change 
> the column name
> that the match is being performed on from 'id-sys' to 
> 'id_sys' I can execute
> the query without having to worry about quoting the column name and
> everything works.  I think that I am just going to leave the 
> column name
> changed and take this as a lesson never to use '-' in a 
> column name again.

Well, if you stop to think about this for a second, it may occur to you to wonder how 
MySQL is supposed to tell the difference between the column name id-sys, and the 
expression id-sys (i.e. the value of the id column minus the value of the sys column). 
 The answer is that you have to demarcate a column name like this that is ambiguous -- 
and in MySQL that's with ` back ticks.  (Other databases have other means of doing 
this -- or just restrict column names to avoid the issue!)

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DB] Update Query Help...

2002-12-10 Thread 1LT John W. Holmes
> I have definitely isolated the problem.  If I change the column name
> that the match is being performed on from 'id-sys' to 'id_sys' I can
execute
> the query without having to worry about quoting the column name and
> everything works.  I think that I am just going to leave the column name
> changed and take this as a lesson never to use '-' in a column name again.
> Thanks again for the help.  Maybe we all learned something from
> this.

If you want to use a column name like id-sys, which you shouldn't, though,
as you've learned, you can enclose it in backticks, like `id-sys`. Note that
those are not single quotes, they are backticks, to the left of the number 1
key.

---John Holmes...


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP-DB] Update Query Help...

2002-12-10 Thread NIPP, SCOTT V (SBCSI)
I have definitely isolated the problem.  If I change the column name
that the match is being performed on from 'id-sys' to 'id_sys' I can execute
the query without having to worry about quoting the column name and
everything works.  I think that I am just going to leave the column name
changed and take this as a lesson never to use '-' in a column name again.
Thanks again for the help.  Maybe we all learned something from
this.

-Original Message-
From: DL Neil [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, December 10, 2002 2:00 PM
To: NIPP, SCOTT V (SBCSI); '1LT John W. Holmes'; [EMAIL PROTECTED]
Subject: Re: [PHP-DB] Update Query Help...


SCOTT,
The list's crystal ball filter is down for maintenance.
Show us the tbl schema and the debug print of $update.
Then we won't be firing blind!
=dn


> I understand that the column name does not normally need quotes, but
> without quotes on the column name I get a mysql error message about no
> column named 'id'.  Unfortunately, I cannot even get the UPDATE statement
> working outside of PHP through an direct SQL statement.  Everything looks
> like it should work, but the affected columns is always zero, and
obviously
> the atime column is not getting the timestamp.
> This is quite frustrating.  Thanks again for the help.  Hopefully
> someone will come up with something to help me get this working.
>
> -Original Message-
> From: 1LT John W. Holmes [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, December 10, 2002 1:45 PM
> To: NIPP, SCOTT V (SBCSI); [EMAIL PROTECTED]
> Subject: Re: [PHP-DB] Update Query Help...
>
>
> > $tmp = $_POST['sbcuid']."-".$_POST['system'][$a];
> > $update = "UPDATE accounts SET atime='NOW()' WHERE
> > \"id-sys\"='".$tmp."'";
> > echo $update;
> > $result1 = mysql_query($update, $Prod) or die(mysql_error());
> > echo mysql_affected_rows();
>
> Try:
>
> $update = "UPDATE accounts SET atime=NOW() WHERE id-sys='$tmp'";
>
> NOW() is a function, don't enclose it within quotes and make it a string.
> You don't put quotes around column names, either, only string values.
>
> ---John Holmes...
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DB] Update Query Help...

2002-12-10 Thread DL Neil
SCOTT,
The list's crystal ball filter is down for maintenance.
Show us the tbl schema and the debug print of $update.
Then we won't be firing blind!
=dn


> I understand that the column name does not normally need quotes, but
> without quotes on the column name I get a mysql error message about no
> column named 'id'.  Unfortunately, I cannot even get the UPDATE statement
> working outside of PHP through an direct SQL statement.  Everything looks
> like it should work, but the affected columns is always zero, and
obviously
> the atime column is not getting the timestamp.
> This is quite frustrating.  Thanks again for the help.  Hopefully
> someone will come up with something to help me get this working.
>
> -Original Message-
> From: 1LT John W. Holmes [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, December 10, 2002 1:45 PM
> To: NIPP, SCOTT V (SBCSI); [EMAIL PROTECTED]
> Subject: Re: [PHP-DB] Update Query Help...
>
>
> > $tmp = $_POST['sbcuid']."-".$_POST['system'][$a];
> > $update = "UPDATE accounts SET atime='NOW()' WHERE
> > \"id-sys\"='".$tmp."'";
> > echo $update;
> > $result1 = mysql_query($update, $Prod) or die(mysql_error());
> > echo mysql_affected_rows();
>
> Try:
>
> $update = "UPDATE accounts SET atime=NOW() WHERE id-sys='$tmp'";
>
> NOW() is a function, don't enclose it within quotes and make it a string.
> You don't put quotes around column names, either, only string values.
>
> ---John Holmes...
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP-DB] Update Query Help...

2002-12-10 Thread NIPP, SCOTT V (SBCSI)
I understand that the column name does not normally need quotes, but
without quotes on the column name I get a mysql error message about no
column named 'id'.  Unfortunately, I cannot even get the UPDATE statement
working outside of PHP through an direct SQL statement.  Everything looks
like it should work, but the affected columns is always zero, and obviously
the atime column is not getting the timestamp.
This is quite frustrating.  Thanks again for the help.  Hopefully
someone will come up with something to help me get this working.

-Original Message-
From: 1LT John W. Holmes [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, December 10, 2002 1:45 PM
To: NIPP, SCOTT V (SBCSI); [EMAIL PROTECTED]
Subject: Re: [PHP-DB] Update Query Help...


> $tmp = $_POST['sbcuid']."-".$_POST['system'][$a];
> $update = "UPDATE accounts SET atime='NOW()' WHERE
> \"id-sys\"='".$tmp."'";
> echo $update;
> $result1 = mysql_query($update, $Prod) or die(mysql_error());
> echo mysql_affected_rows();

Try:

$update = "UPDATE accounts SET atime=NOW() WHERE id-sys='$tmp'";

NOW() is a function, don't enclose it within quotes and make it a string.
You don't put quotes around column names, either, only string values.

---John Holmes...

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DB] Update Query Help...

2002-12-10 Thread DL Neil
SCOTT,

> I am attempting to UPDATE a table and I have having absolutely ZERO
> success.  Here is the query:
> $tmp = $_POST['sbcuid']."-".$_POST['system'][$a];
> $update = "UPDATE accounts SET atime='NOW()' WHERE
> \"id-sys\"='".$tmp."'";
> echo $update;
> $result1 = mysql_query($update, $Prod) or die(mysql_error());
> echo mysql_affected_rows();
> Please help me figure out why this is not working.  I have tried
> quoting the column name 'id-sys' every way I can think of, but nothing
> works.  The column is initially NULL, and I am attempting to update just
the
> single column with a timestamp.  Thanks in advance.


NOW() is a function and should not be part of a quoted string.
=dn


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP-DB] Update Query Help...

2002-12-10 Thread SELPH,JASON (HP-Richardson,ex1)
is it a mysql field type of datetime?

if so, you may want to use this instead
$timestamp=date("Y-m-j H:i:s");
$update = "UPDATE accounts SET atime='$timestamp' WHERE id-sys='$tmp'";

that puts the current timestamp in mysql format for entry into your table.

Cheers
Jason

-Original Message-
From: NIPP, SCOTT V (SBCSI) [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, December 10, 2002 1:35 PM
To: '[EMAIL PROTECTED]'
Subject: [PHP-DB] Update Query Help...


I am attempting to UPDATE a table and I have having absolutely ZERO
success.  Here is the query:

$tmp = $_POST['sbcuid']."-".$_POST['system'][$a];
$update = "UPDATE accounts SET atime='NOW()' WHERE
\"id-sys\"='".$tmp."'";
echo $update;
$result1 = mysql_query($update, $Prod) or die(mysql_error());
echo mysql_affected_rows();

Please help me figure out why this is not working.  I have tried
quoting the column name 'id-sys' every way I can think of, but nothing
works.  The column is initially NULL, and I am attempting to update just the
single column with a timestamp.  Thanks in advance.

Scott Nipp
Phone:  (214) 858-1289
E-mail:  [EMAIL PROTECTED]
Web:  http:\\ldsa.sbcld.sbc.com



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DB] Update Query Help...

2002-12-10 Thread 1LT John W. Holmes
> $tmp = $_POST['sbcuid']."-".$_POST['system'][$a];
> $update = "UPDATE accounts SET atime='NOW()' WHERE
> \"id-sys\"='".$tmp."'";
> echo $update;
> $result1 = mysql_query($update, $Prod) or die(mysql_error());
> echo mysql_affected_rows();

Try:

$update = "UPDATE accounts SET atime=NOW() WHERE id-sys='$tmp'";

NOW() is a function, don't enclose it within quotes and make it a string.
You don't put quotes around column names, either, only string values.

---John Holmes...


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DB] UPDATE query to add to a field

2002-01-28 Thread DL Neil

Hello Adv. Systems Design,

> I need to be able to update a field in MySQL, the catch is that I have to add on to 
>text that is already there
and I have to be able to do it within MySQL (phpMyAdmin). My first idea was to do:
>
> SET prod_desc = prod_desc + "more info to tack on to end"
>
> but this is a mathematical function which returns 0!
>
> Any ideas?


SET prod_desc = CONCAT( prod_desc, "more info to tack on to end" )

Manual: 6.3.2  String Functions

Regards,
=dn



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] UPDATE query to add to a field

2002-01-28 Thread Joffrey van Wageningen

> SET prod_desc = prod_desc + "more info to tack on to end"
> 
> but this is a mathematical function which returns 0!

update table set field = concat(field, "more info") where id = 1;

find the string functions in the mysql manual...

with kind regards,
Joffrey van Wageningen


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] UPDATE query to add to a field

2002-01-28 Thread Paul DuBois

At 9:06 -0800 1/28/02, Adv. Systems Design wrote:
>hello all:
>
>I need to be able to update a field in MySQL, the catch is that I 
>have to add on to text that is already there and I have to be able 
>to do it within MySQL (phpMyAdmin). My first idea was to do:
>
>SET prod_desc = prod_desc + "more info to tack on to end"
>
>but this is a mathematical function which returns 0!

Use CONCAT().

>Any ideas?
>
>Thanks


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] Update Query?

2001-10-02 Thread Dobromir Velev

Hi,
The query code seems fine to me - did you try to otput $query to see if all
the variables you are using are OK. May be $order,$stationid or $orderNewsID
is misspeled or is not set properly.

HTH
Dobromir


-Original Message-
From: Jay Paulson <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED] <[EMAIL PROTECTED]>
Date: Tuesday, October 02, 2001 2:22 AM
Subject: [PHP-DB] Update Query?


>Hello-
>I'm trying to run an update query in an application I'm making.  I keep
>getting a MySQL error however when I try and print out the mysql_error()
>nothing is returned.  I run the same query in phpMyAdmin and the query runs
>fine.  Below is the update query I'm running and the php code that I'm
using
>to build it.  Any suggestions?
>
>update news set newsOrder=2 where station_id=5 and id=3
>
>$query = "update news set newsOrder=".$order." where station_id=$stationid
>and id=".$orderNewsID;
>
>thanks,
>jay
>
>
>--
>PHP Database Mailing List (http://www.php.net/)
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>To contact the list administrators, e-mail: [EMAIL PROTECTED]
>
>


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] Update query problem (Oracle)

2001-03-28 Thread Steve Farmer

Hi Francesco,

Probably the easiest way is to load the records from table 2 into an 
array and then lopp through updatign table 1

HTH
Steve

At 9:37 AM +0200 28/3/01, Francesco D'Inzeo wrote:
>Hi everyone.
>
>The scenario:
>
>Table1  Table2
>Field_01, <- Same as -> Field_01,
>Field_02, <- Same as -> Field_02,
>Field_03, <- Same as -> Field_03,
>Field_04, <- Same as -> Field_04,
>Field_05,   Field_05,
>Field_06,   Field_06,
>Field_07,   Field_07,
>Field_08,   Field_08,
>Field_09,   Field_09,
>Field_10,   Field_10,
>Field_11,
>Field_12,
>Field_13,
>Field_14,
>Field_15,
>Field_16,
>Field_17,
>
>Table1 contains lot of records but Table2 contains just a few.
>The first 4 fields identify records that are common to the 2 tables.
>
>My problem is to write a query that updates for example
>Table1.Field_11 with Table2.Field_06
>Table1.Field_14 with Table2.Field_09
>Table1.Field_15 with constant char 'A'
>Table1.Field_16 with SYSDATE
>
>only for records that are both present on the 2 tables.
>Regards.
>
>---
>"On a day not different than the one now dawning, Leonardo drew the
>first strokes of the  Mona Lisa, Shakespeare  wrote the first words
>of  Hamlet, and  Beethoven began working on his Ninth Symphony, and
>Windows98  aaarrrggghhh crashed for the n'th time"
>---
>  Francesco D'Inzeo
>  WinTech S.r.l.
>  Via Lisbona 7
>  35127 PADOVA (Italy)
>  Tel.   (+39)-(0)49-8703033
>  Fax.   (+39)-(0)49-8703045
>  Mobile (+39)-(0)348-2867140
>  e-mail [EMAIL PROTECTED]
>
>
>
>
>
>--
>PHP Database Mailing List (http://www.php.net/)
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>To contact the list administrators, e-mail: [EMAIL PROTECTED]

-- 
---
"Minds are like parachutes, they work best when open"
Support free speech; visit http://www.efa.org.au/

Heads Together Systems Pty Ltd http://www.hts.com.au
Email: [EMAIL PROTECTED] Tel: 612 9982 6767 Fax: 612 9981 3081 

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]