| 
	
 | 
 Posted by Rik on 01/16/07 21:52 
Andy wrote: 
> This is a table of database I bought: 
> 
> recipes 
>       Field Type Null Default 
>       id   bigint(20)  No 
>       title   varchar(255) No 
>       category   varchar(100) No 
>       incredients   text No 
>       procedures   text No 
>       imagepath   varchar(255) No 
>       notes   varchar(255) No 
>       status   varchar(15) No  Active 
> 
> And this are fields I want to transfer to my recepies database I had: 
> 
> Tables I bought: 
> 
> recipes 
>       Field Type Null Default 
>       id   bigint(20)  No 
>       title   varchar(255) No 
>       category   varchar(100) No 
>       incredients   text No 
>       procedures   text No 
 
Ah, appending to an already existing table, with a different format, that's 
another beast, forget all earlier posts. 
 
It also has nothing to do with php, so in future you might want to ask in 
comp.databases.mysql 
(On a side note, you paid for a database that has a field named 
'incredients'? If they're that careless in naming the fields, I wonder 
wether the data is even worth it...) 
 
But to answer your problem: you'll need several queries, some of which can 
be tricky. 
 
You do not want to transfer the id, because your table already has an id, 
and it will overwrite earlier ones as it is a primary key. We will not use 
the id from the new table. 
 
Also, a category here is a description, while in your normal database it's 
a key, pointing to a description, so you'll have to insert all category 
fields that aren't yet present in the original database. On inserting the 
recipe, you'll have to check which category id they will get. 
 
Also, 'incredients' is text here, while in your database 'ingredients' is a 
seperate table. Without any knowledge what those 'incredients' actually 
hold I cannot tell you how to do this. 
 
I guess 'procedures' from the new table should go in 'story' in the old 
table? Hard to say without their content. 
 
In short: without access to the database/knowledge about the actual 
contents, it's not doable for anyone here to give you the queries to do it 
(mainly because of the ingredients part). There's no such thing as a 
program which will automate this for you, as it would have to have magical 
knowledge about the relevance of certain fields in different tables. 
There's also no short tutorial which will explain it to you, just learn 
some SQL, try with trail and error, and enjoy the learning experience. It 
will be a great benefit in the future. If your hesitant to play with your 
'live' database, just copy some tables under a different name, and play 
with those untill your comfortable you can swap them with the live ones. 
 
If you feel you cannot succeed, or you want this online asap, either give 
someone you know with knowledge of SQL access to the database, or pay 
someone to do this. I'd think anyone with direct access to the database 
will be able to do this within half an hour or so. Unfortunatly, this is 
not something I can do for free here on the newsgroups. 
--  
Rik Wasmus
 
  
Navigation:
[Reply to this message] 
 |