Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8987577
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T21:49:48+00:00 2026-06-15T21:49:48+00:00

Update : What I am actually doing: I am making an ETL tool and

  • 0

Update:
What I am actually doing:

I am making an ETL tool and writing its script in php:
ETL is being designed for specific domain, the provided data is consistent with its structure but there is some dirtyness in the data which is needed to be removed like H.NO , H#, H.NO. should be = HNO :
I am using approach of stored procedure. In which i created a lookup table for wrong values and replacing them with right values so the final stored data should be perfect.

I have to detect the wrong values in the db table and replace them with the right one’s thats all.


I have created an array $find[] that is storing values coming from DB, Then there is a variable $exist , which i want to check if it exists in the $find[wrong] array (column) or not. If It does then its value gets replace with the correspnding cloumn value $find[right]. Kindly let me know how can i do such sort of replacement. Thanks,

Note : My DB table contains only two columns named as wrong and right

When I dump my $find array it gave me the following output:
Array ( [0] => Array ( [0] => FSc [wrong] => FSc [1] => FSC [right] => FSC ) [1] => Array ( [0] => Fsc [wrong] => Fsc [1] => FSC [right] => FSC )

CODE:

$lookup = mysql_query("select * from lookup");
while($getlookup = mysql_fetch_array($lookup))
{
$find[] = $getlookup; 
}
print_r($find);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T21:49:49+00:00Added an answer on June 15, 2026 at 9:49 pm

    OK you need to simply change your query to this

    "SELECT right FROM lookup WHERE wrong = '" . $exists . "'"
    

    This will return 0 rows if there is no match. Or one (or more rows depending on how table is setup) if there is a match.

    You should have an index on your wrong field to optimize the query. If there should only be one specific value of right for any value of wrong (i.e. wrong is unique on each row), then make wrong a unique index to enforce it’s uniqueness.


    Updated answer to match your revised question. What I would do is simply use an SQL query to update your bad data from your mapping table.

    So I am assuming you DB structure could look something like this:

    the_table
    ---------
    the_field (the field you are trying to change)
    ... some other fields
    
    mapping_table
    ---------
    wrong
    right
    

    Then the query you would need to run to update the table with sanitized values would like this

    UPDATE the_table AS t
    INNER JOIN mapping_table AS mt ON t.the_field = mt.wrong
    SET bt.the_field = mt.right
    

    This would update the table in place to the new values. Obviously, if you didn’t want to change the table in place, you could make a copy of the table and then run this query against that table copy.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm not seeing why my update statement isn't actually updating. Here is what I
We're repetitively making a CGLayer, doing processing, and then releasing it. This happens a
UPDATE: OK, Tesla (user) solved most of this with a php snippet (down below),
When doing a cvs update , you get a nice summary of the state
UPDATE It turns out that the code below is not actually the problem. In
When writing destructive queries (e.g., DELETE or UPDATE) in SQL Server Management Studio I
Update: Is there a way to achieve what I'm trying to do in an
update: I mistyped 2 variables...so embarrassing. thanks everyone for the effort! sorry i find
Update: I reported this as a bug to Apple and they fixed it! All
UPDATE: I've been playing around with this more, and it seems like tmux's clear-history

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.