Log in

View Full Version : mySQL tip needed


KhaN
04-20-2004, 08:59 AM
I need to sort item column into a file, like a text file.
Result will be a text file with all items names/ID that i will be able to consult.

It is possible ?

Derision
04-20-2004, 09:11 AM
mysql -u root

use eq;
tee items.txt
select id,name from items;
quit

that will write the id and name field for each item to items.txt

Is that what you are after ?

KhaN
04-20-2004, 09:50 AM
YOU are the man !

Thanks alots :)

KhaN
04-21-2004, 12:25 AM
Another request, is there a way to copy/paste using mySQL command or mySQL Front.

Lemme explain, im making spells, there are 11 spells of the same type, only prefix name change, and editing 11 items is way to long, it could be cool if i can create one, copy/paste the 10 others and just edit the name/ID.

Thanks in advance.

Derision
04-21-2004, 01:14 AM
I am not sure this is what you want, but ...

If you want to insert 10 new items based on an existiing item, use mysqldump to dump the record you want, in this example, item number 1001:

mysqldump -u root eq items --where 'id=1001' >mytems.txt

If you look in myitems.txt, you will have the SQL to create the item table (which you can delete), followed by an INSERT statement, e.g.

INSERT INTO items VALUES (1001,0,'Cloth Cap',0,2,0,0,0,0, ......

Copy and paste this statement as many times as you like, changing the ID to something unique, and changing the item name and whatever other fields you want.

Then just source the file into mysql.

KhaN
04-21-2004, 01:20 AM
This exactly what i needed, this way i can make on item with "spell template" and just edit ID, Item name, Effect. Faster then editing all items using item editor, especially when you have 2500 spells to write ...

Thanks again Derision :)

Edit : Tried at home, that dont work ...
Command i type is
mysqldump -u -root eqa items --where 'id=1102' > items.txt;
Got Error 1064. Tried to change some thigsn, but i cant find.

Edit :LMAO, mysqldump is DOS command. How to lose 2hrs ... geez

KhaN
04-21-2004, 06:48 AM
i cant enter "INSERT INTO ...' because mysql dont take the whole line. look like its restricted to a certain number of characters ...

Derision
04-21-2004, 06:56 AM
Just copy and paste the lines in a text file with notepad, make your id and name changes, then save it, go into mysql and type 'source <yourtextfile>'