Link to home
Start Free TrialLog in
Avatar of Deacil
DeacilFlag for United States of America

asked on

MySQL Newbie Question

I am embaressed to ask but is there a tutorial site that I can look at to help me.  I am simply trying to take data from 2 MySQL databases format the data and insert the result in another database.

I am using Navicat and making my way through everything but don't want to loose anymore hair and waste time when it is something simple like this.

Thank you in advance.
Avatar of Mark Brady
Mark Brady
Flag of United States of America image

Hi there

There are truck loads of free tutorials for beginners right up through advanced out there. you only have to google them but my advise is to actually post what you are trying to achieve right here and we will show you how to achieve it. We will even write and post the code for you.

Getting data from one database table and inserting it into another database table even in a different database is very simple. If you can be more specific, we can give you precise answers with examples if you want. Welcome to mysql by the way.
Avatar of Deacil

ASKER

Thank you.  I spent some time on Google last night and found bits and pieces of info.  First let me say, I took down my servers a month or so ago and trying to use MySQL on GoDaddy (don't laugh).  This small project doesn't warrant me turning my servers back on.

Here is what I am trying to accomplish.  So I get 2 XML files every day.  The data is similar but 1 overrides everything in the other if it is different.  I would like to pull the info into a 3rd database which would be a clean self-containing file that I can use PHP to modify the db.  The biggest piece is the data in either file needs to be formatted with HTML tags so that I can import it into a website.  The data is a product database for an eCommerce site, approximately 5000 records.

The reason for the PHP edit is some products might need to be adjusted (price, availability, stock, etc...)  In addition to the HTML formatting I will also need to do some calculations such as price * 30%.  

I have tried with some success to do this in excel but it is miserable.  I have minor MySQL experience but have always wanted to know a lot more.

Thank you for the reply.
Well you could do that in mysql and adjust the records using
PHP and php would display the records. You definately need a server that has both Php and mysql installed on. What you describe is a normal commercial type website that has CMS attached. That is a login section where the owner/operator can login and update/edit records and the changes are immediate on the website. Very common. In fact that's what I build on a daily basis. Not cheap though but you can either download something like drupal and build your own, or learn php/mysql and build your own, or pay a developer to build it for you.

Or of course if you are trying to do just one thing you could ask how to do it on here (EE) but we don't do full projects.
Avatar of Deacil

ASKER

Thank you for the reply.  I understand about the full project, and I wouldn’t do that to anyone without compensation.  I was just trying to answer your question of providing more specifics.

I guess the only thing I want to find out what is the command or function to do a compare of one field and then insert the match to a different database/table.  If you only want to point me in a direction on the web I understand.  I don't mind doing the research and learning something new.  I am just trying to save a few hours and a headache from staring at a screen reading multiple sites.
There is no specific function to look at data and compare it but I can write one for you. Firstly, I need to know what the tablename is and what sort of data is in there. What is it being compared to and what will you called your other table? Are both tables going to be in the same database or do you want it in a separate database? You can have both the tables in the same DB if you want, it would be easier.

Anyway, give me a little more info on what you want to compare (some examples) and I will write you a Php code to fetch the data from mysql and compare it to something then insert it into another table. Does it need to match something before you insert it into the different table or what? How does that work?

Thanks
Avatar of Deacil

ASKER

You are awesome!

All are in 1 db now.

Table 1 / Field {Product ID} match to Table 2 / Field {Stock_Code} items in record (Table 2 records) should be entered in Table 3 (same field names as Table 2).  Fields to be inserted/updated are {Brand} {Title} {Price}

Thank you again.  There are a lot more fields but that will get me started in a HUGE way!
So can you give a quick example of a record for all three tables so I can get a hold of this. Then I can write an insert/update query to update or insert into the tables. Thanks.

What I need is something like

table1_name // the actual name for this table
list the columns in this table then put an item beneath each column so i can see how it should look. Just a quick example would be ok. Show all three tables though.
Avatar of Deacil

ASKER

Thank you for looking at this.  The table names are just table1, table2, table3.

I hope the attached images explain things a little better.

Anything you can offer would be great!  Even if it is go buy a book.

Thank you again.
 User generated image User generated image User generated imagetable3.JPG
ASKER CERTIFIED SOLUTION
Avatar of Mark Brady
Mark Brady
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Deacil

ASKER

Sorry for the delay in response.  I have been away and hope to be able to check out the code early next week.

Thank you again for all your help!  The code looks like exactly what I needed.
Thanks for the points. Yes it should work just fine but let me know if you have any problems with it or don't get the desired results and I will adjust the code for you. Good luck.