Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    MYSQL




Replace All Blanks


I don't know why I'm getting an error that says:
"Query returned no resultset."
I check the table and nothing was changed.

Here's my code:


UPDATE GFER2 SET part_num = REPLACE(part_num,'','0')




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
How To Universally Act On All Cells In A Table, Turning Blanks To NULLS
i should be able to do this, but it's actually been a pain for a while. how can i turn all the blanks in a table to NULLS?

Replace
If I need to replace word [one] with word [two] in a single table within one mysql database, how is this to be done?

Using REPLACE()
how to use "replace()". Basically I am looking for a way to tell replace to only perform the function if the pattern is at the beginning of the string. So...

I am attempting to rename every instance of "Nate" (in a column) to "Nate/Nathan"

UPDATE table SET column=REPLACE(column, "Nate", "Nate/Nathan");

That part works fine. It also works well if the value is "Nate/Nathanial", changing it to "Nate/Nathan/Nathanial"

What REPLACE() also does that I do not want it to do is take "John/Nate" and replace that with "John/Nate/Nathanial" I only want it to perform that search for "Nate" starting at the 0 index spot.

Because MySQL has another function called REPLACE (acts as an UPDATEDELETEINSERT all-in-one utility) I can't seem to find any information on replace().

REPLACE
I am trying to replace as follows :

SET @BEFORE='http://whatever.com/pn/index.php?name=PNphpBB2&file=viewtopic&t=';
SET @AFTER='http://whatever.com/forums/viewtopic.php?t=';
UPDATE table SET column =REPLACE(column,@BEFORE,@AFTER);

but this is not working correctly, maybe because of the question marks "?" and the & marks in the statements. (right?)

how could I escape the "?" ?

how can I make this "http://whatever.com/pn/index.php?name=PNphpBB2&file=viewtopic&t=" be read as a "simple text" expression to be replaced as I am trying to do?

REPLACE
Is there a such function where I can replace more than 1 thing in 1 function?
For example, I know this exists:
REPLACE(string, old_value, new_value)
But, is there any way where I can replace more than one thing...kinda of liek in a list
like old_value_1, old_value_2, new_value_1, new_value_2

Replace
i am trying to use replace on a table however the unique key is not a single column. How can i set the unique key to be a combination of two columns in the table?

Partial Replace
I have a field called ref_no containg data like this:

14a-12395

How would I replace the 14a- part to be left with 12395 ?

PS, the 14a could vary with the no of characters, ie it could be

9a-

or 124a-

Ive tried THIS, but it doesn't affect any rows:

update company_tbl_copy set ref_no = replace(ref_no,'%-','');


Replace ... Select?
I am trying to create a query that goes through a table of orders in the last 30 days and caches a list of the best selling items (and saves it to another table). I know that I can do this in two queries, but I am trying to force myself to use just one... The table I am saving is very simple -- product_id [unique, int(10)] and quantity_sold [int(10)].
My current query is:

MySQL
INSERT
  INTO BestSellingProducts_Cache
     ( product_id
     , quantity_sold
     )
SELECT OrderItems.product_id AS OrderItems_product_id
     , SUM(OrderItems.quantity) AS OrderItems_quantity_sum
  FROM Orders
  LEFT OUTER
  JOIN OrderItems
    ON Orders.id = OrderItems.order_id
 WHERE Orders.orderdate >= ?'
 GROUP
    BY OrderItems.product_id
Unfortunately, since product_id is unique the second time I run this query I get a duplicate key error. I thought I might be able to append
MySQL
ON DUPLICATE KEY
UPDATE
   SET quantity_sold = OrderItems_quantity_sum
But I can't do that when I use a GROUP BY in my SELECT.

I could easily empty the table before running the query, but since this will be running as a cron job, I wouldn't want the table left empty if there was ever a server hiccup or something and the second query dies. Is it possible to create a TRANSACTION with MyISAM and TRUNCATE?

is there a REPLACE INTO ... SELECT type query? None of these queries "age off" old data, but I think I would be okay with that... I'll have to run that spec by the bosses

Search & Replace?
Newbie here.

I have a DB with two tables.

Table 1 has three fields - a unique ID#, a first name (i.e - John), and a last name (i.e. - Smith).

Table 2 had many fields, one of them being a first name/last name combination (i.e. John Smith).

I want to replace the first/last combo field in table 2 with the unique ID# from table 1 which matches the concat of the first name field and the last name field from table 1.

I know I can do it by hand, but there are thousands of them in table 2 that need to be replaced and the data in table 2 is in the format that I will be receiving from an outside source, so I will need to search & replace this data on a regular basis.

Search And Replace
I want to replace a string inside a text field named "text".  

Here is a query which would show the records which contain the offending code which I want to strip out:

SELECT * FROM articlestable where text like Concat('%', '<b class=titler>', '%', '</b>', '%')

Replace A Substring
I,ve got a table called CUSTOMER which is defined as follow :

CUSTOMER
-------------

ID | FIRST NAME | LAST NAME

here are some values :
125 | Nicolas | Fijean
250 | Tom | wood
285 | Sylvain | Cox
(...)

I would like to replace the ID as follow : all ID beginning with 2xx should be 3xx (example : 250 => 350, 285 => 385, ...).

REPLACE Vs. One To Many Relationships
To describe the problem, let me first present a hypothetical database, perhaps used to track students. This database consists of two tables.

The first table "students" has two attributes: a primary key called "ssn"(primary key unique not null) that tracks the student's SSN, and a second attribute "name" that tracks their name.

The second, "classes", also has two attributes, "fk_ssn"(not null references students(ssn)), and "class" (Varchar) which represents the classes they have taken. This essentially represents a one-to-many relationship.

The problem is this: I am doing updates to a similar database in php, inserting table by table. That is, I first insert into students, and then into classes. When using REPLACE syntax, MySQL will notice that the primary key in students exists already, and replace the existing record. However, since the classes.fk_ssn cannot be unique (recall: one to many), it cannot be a primary key, and thus, MySQL simply adds another duplicate record rather than replace the existing one.

My question is, does anyone know an elegant way to deal with this problem?

Replace Statement
I am trying to create a table and define a column using the replace statement but I get an error saying it is invalid syntax. The same syntax works okay in MSSQL, any ideas on what is wrong with the following syntax?

AC_KEY0 AS REPLACE(STR(AC_YEAR,004,00), ' ', '0')

Replace Id In Two Rows
I have a table where id is int and two simpe rows

+----+
| id |
+----+
10
+----+
15
+----+

and I want to replece id values in both rows. Now first row must be 15 and second 10

I can do this in 3 steps : 1. change in first row id =20 2. in second id=10 3. in fors row id=15(in my table more than 2 rows)The question is there function which do this in one step?

Replace Function
I am not an experienced user of MySQL and we are trying to produce a basic report but we are having trouble getting the replace function to work. We have a unique indentifer (contract id) from a finance package but need to delete the suffix "CS" from the contract id : we have used the following code:

REPLACE(ContractId, 'CS', ' ')

However, when we run our Crystal report the contractid is limited to a string of 6 yet we need to ensure that at least 10 char are returned.

Find And Replace
In entering information into my database, I've added a line of code into the main description field of every entry that I'm now having second thoughts about.

Is there a way I can do a find and replace operation on every description field to strip out the unwanted code?

Replace Word
I would like to know that is there any way to replace the particular word from the sentence by using Mysql query.

For e.g.->
I have records in the Mysql table like…

CodeParticulars
101This is the $abc. I am $xyz for help.

In the above records, I would like to replace
$abc – Help topic
And
$xyz – searching

Find And Replace
In a field I will first FIND all instances of the following:

a DOT, a SPACE and ANY SMALL LETTER ie. ". a" or ". b" or ". z"

Then I will REPLACE this string with "SPACE SMALL LETTER" ie. I will remove the DOT.
Would you write the appropriate expression for this scenario?

Does Mysqldump Replace Everything?
I've made design changes to a test MySQL database on my local machine, and I would like to replace the MySQL database on my Internet server (which is also currently a test db).

Does the mysqldump command wipe out everything in the target database, and replace the *all* the objects (tables, indexes, relationships etc) and data?

Regexp, Replace ?
I am new to regular expressions and I need to know if they can help in solving this problem, I have a field in a table called "identification" which is a text field that includes dots (.), commas (,), hyphens (-) and letters, plus numeric characters. What I want to do is to extract ONLY the numeric characters from the field. Example of the field identification:

V-1.234.567, I would like as a result to obtain just 1234567. Any ideas on how to do this???

Find And Replace
I want to find Data and replace it. For example: I have a bunch of Data that looks like

356-A
357-A
358-A

I would like to be able to remove all the dashes without having to do it one by one in MySql. Any ideas?

Mysql Replace
I have a large database with text strings.

What is the quickest way to replace each ['] with a ['] throughout
the database fields while leaving everything else intact?

ex

.... I'm a monkey ...

becomes

.... I'm a monkey ...

etc.

Replace The First Occurence
Please help on the following:

I've the need to replace the first occurence of some text,
for example;

abcd///abcd:efg///

I need to replace the first abcd///
so that it displays abcd:efg///

anything in mysql query that has something similar to the php preg_replace?

Replace Query
I have a Mysql database using Phpmyadmin. I want to run a query on a table to replace some data. Let's call the table my_table and the fields field1 and field2. I need a query that searches my_table for instances where field1 is not identical to field2 and in the resulting instances replace field2 with field1.

Replace Function
I have two tables
I need to replace values 'Field61' and 'Field62' from table 'keyword' from source 'descripcion' and 'numero' from table capital where the FileID from table keyword is equal to FileID from table capital

y think on this

REPLACE INTO keyword (Field61)
SELECT descripcion
FROM capital C WHERE C.FileID = FileID --->(how do that this FileID be a keyword.FileID???)

Regexp And Replace
I have a chemicals table with chem_id,chem_name, et al. I just received a large amount of new input which may or may not match the chemicals already in my table. I need to match the new chemical names against chem_name. I've already done a straight text match with some success. However chemical names are complex and contain many non-alphanumeric characters. I'd like to compare the new and old chemicals names with the odd characters and spaces removed. I know I could do a nested replace, but I was wondering if there were any easier way of cleaning the chem names?

Conditional REPLACE
suppose that there is a text like following (in datasore table)
Quote: "cookiedomain";s:11:"devshed.com"

i can change it using following query

 UPDATE datastore SET data = REPLACE(data,
'"cookiedomain";s:11:"devshed.com"',
'"cookiedomain";s:0:""') 

but there are somethings i do not know between quotes so i want create a query like "if there are somethings between quotes" namely "in between quotes are blank"

Replace Function
I am trying to do an update/replace function in MySQL but I am getting MySQL error #1064. Basically the query is just trying to update a field called Description in a table called Widgets by changing some values to a new value. So, for example, I want to change the field 'oldvalue123' to 'newvalue123'

The query works well in MS SQL 2000 but not in MySQL- Here is the query

Update Widgets
Set Description = (Select Replace(Description,'oldvalue','newvalue'))
From Widgets

REGEX In A REPLACE
PHP Code:

 SELECT products_id, products_name, products_price, products_image,
LCASE(REPLACE(REPLACE(products_name, '&', 'and'), ' ', '_')) as seo_url,
 FROM products
 WHERE products_parent = {$this->_id} 

Is it possible to replace the double REPLACE calls with some sort of Regular Expression? I'd like to make seo_url i.e.

"product's name" -> "products_name"

Mysql Replace
SELECT REPLACE(REPLACE(REPLACE (
Message,
"!FIELD1",
Field1
), "!FIELD2",
Field2), "!FIELD3",
Field3) AS RMessage
FROM customized, customized_messages
WHERE customized.ClientID = customized_messages.ClientID

anywong with it ? i got error....with the !FIELD

Replace/update
I used phpMyAdmin to build my MySql database. I entered the records in alpha order according to the primary key. I need to make minor spacing and formatting changes in these records. I still have the records stored in a text file exactly the way the records were cut and pasted into phpMyAdmin. I used the INSERT statement to insert the records in the database. Is there a command I can use with these records to copy over or replace the records I already have in the database by changing the INSERT statement to something else like UPDATE, REPLACE, CHANGE, REDO, COPY OVER or whatever it takes.

I can make the changes I need in the text file with a word processor, copy the records, paste the records into PhpMyAdmin like I did originally if I can find a way to replace the records that are already in the database.

Replace NULL
I searched six pages of NULL information, and learned a lot about NULL conditions in MySQL, but it didn't help me figure out my own desire.

I'm performing a very simple query:

SELECT * FROM MONSTER;

The table returns with over 200 columns. Some values may be NULL. Is there an easy way to replace "NULL" with a string value, such as "NOTHING"?
It sure would be sweet if there is!

Upon Googling it, it looks like MSSQL has an "ISNULL(field, "replacewith") function. Just wondering if there's a way to do it within a MySQL query.

MySQL Replace
Total noob here.

I have a table:
mos_downloads_files
that has a field:
url

All of the records in this field have a value like:
http://cs13.simplehost.com/~vcchurch/mambo/...

I need to replace that with:
http://vcommunity.org/mambo/...

How can I do this in PhpMyAdmin?

Replace In With JOIN
i am a newby, can someone tell me how to rewrite the following:

select id,online_datum,aanvraag_datum,naam from campagnes where status='A' and (id not in (select cid from affl_campagnes where affl_id='12345')) order by online_datum desc

to a line without the IN (my provider does not accept IN)

Replace Contents
I have a table called "popp_imglibrary"
I want to overwrite the contents of a field in it called "caption" with the data from another field within the same table called "imgname"
I real noob question but should I use the replace command?
If yes then please could somebody help me a bit with the syntax?

Replace In MySQL
I am trying to do an update/replace function in MySQL but I am getting MySQl error #1064. Basically the query is just trying to update a field called Description in a table called Widgets by changing some values to a new value. So, for example, I want to change the field 'oldvalue123' to 'newvalue123'

The query works well in MS SQL 2000 but not in MySQL- Here is the query

Update Widgets
Set Description = (Select Replace(Description,'oldvalue','newvalue'))
From Widgets

how to get this to work in MySQL?

Remove With Replace
I have a problem with apostrophes. I accidentally imported a ton of data that included apostrophes and need to remove them from my database (they are messing things up when the info comes back out again).

I have tried these commands,

update `st_galleries` set `text_description` = replace (text_description,"'","");

update `st_galleries` set `text_description` = replace (text_description,char(39),"");

update `st_galleries` set `text_description` = replace (text_description,"char(39)","");

And each time mysql does not seem to see the ' character and comes back with all matches but no changes. By all matches I mean it comes back with 5641 matches (I don't have that many apostrophes, I do have that many rows).

Search And Replace
Have a website where we have just changed domain names, but am having a problem because content has been submitted that occasionally uses absolute URL's which has resulted in lots of links through the site pointing to the old domain.
What I want to be able to do is do a search and replace in MySQL that replaces all use of the old domain name with the new one. I've found several search and replace guides around the internet, but they all seem to do a search and replace on a specific field on a specific table like this on;
Code:

UPDATE tablename SET tablefield = replace(tablefield,"findstring","replacestring");

Find And Replace
I need a a mysql query that i can run on a certain field in a table and get all entrys that contains a certain bit of info and the replace it with something else, so basically a find a replace query,So what would the query be to do this?

Update (basically Replace)
I have a table with 100 fields, that I want to update with the data from a different table, that contains the exact same field names and number, except for one.

Do I need to do this:
PHP

UPDATE newsletter SET temp_id = (SELECT temp_id FROM templates WHERE template_name = $template),
For each field I want to update, or is there an easier way?

Replace Or Delete Specified Value In A Field
I can write some php script to do this but was wondering if there was a simple way to take care of it in mySQL. I have a field that has some values prefixed with "imported_" ie. imported_california. Is there a sql statement I can use that will delete every instance of "imported_" in this field?

A Complex Find And Replace
I have a table with a column I need to modify, I think, with a find and replace.

The column contains a number currently with no decimals that I need to convert to a number with a decimal. I need to add a decimal 6 numbers from the right. For instance, 12345678 needs to become 12.345678. All of the numbers have will have at least one number to the left of the decimal, sometimes with 2 or 3 and possibly a negative sign. (They are lat and long coordinates that did not come with a decimal in them.)

Does anyone have any thoughts on how to accomplish this with MySQL or, as a last resort, outside of MySQL?

Search & Replace In Database?
I want to change a website from XHTML to HTML, so I have to get rid of my closing tags, such as...

<meta tags />
<image src="" />
<br />

I can clean up most of my site with Dreamweaver's search and replace function. Is there a way to do something similar with my database, preferably using phpMyAdmin? If so, will it let me use regex (for meta tags and images)?

Also, I know how to use phpMyAdmin's Search function, but is there a way to search for a specific item in a field, like " />" or "<br />"?

Serach And Replace In Mysql
Is it possible to search and replace some of the content of this column?

How Do I Use REPLACE Function With A Txt File
I have a sql table with about 9 fields of data in it.The first 3 are filled and the last 6 are currently blank. I have a tab delimited .txt file containing data for each of the 9 fields and want to import it in phpmyadmin to both overwrite the existing data in the 3 fields and fill out the other 6.

However I only want to import the data where one of the existing filled-out fields "TournamentID" equals 10. In this previous thread
a poster recommended using REPLACE after making the first 3 columns a Unique Key.

I know how to change the key for the variables. However I'm still not sure how I use the REPLACE function with data in a .txt file. Is that possible? I can only access my database via phpmysqladmin.

Use MYSQL Replace With A Variable?
I have a field that is made up of a bunch of email addresses. I want only the part of the field that comes before the "@". How do I modify my replace statement to do this? It tried using the "%" after the "@" but that did not work.

Replace From A File Syntax
I'm trying to use the replace function to do exactly what is described in the manual. The twist is that I want to replace the rows with data that is in a text file. The manual seems only to indicate how to replace one row at a time:

MySQL Find And Replace
I need to replace a string of text everywhere that it appears in a particular field.

Specifically, I need to replace the word Interbrew with InBev in every instance that it appears in the Inl_custom table cust5 field. I also need to make sure that only the word Interbrew is replaced rather than replacing all of the text in that row. Is there a MySQL command that can do this?

Replace Text In Fields
I've a text field in which data is stored as HTML.

I want to replace urls in the text field with another url.


Copyright © 2005-08 www.BigResource.com, All rights reserved