Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Simple question about sql

Quote Reply
Simple question about sql
Dear All,

I want to use the SQL monitor to add multiple similar categories such as category A to Z alphabetic listing. I know little about sql and I understand that I need to write a sql command that is something like "insert col... value...". My question is do I need to take care of the category ID or the db will increament it automatically? I would appreciate it very much if somebody could write a sample sql command for use in the SQL monitor to add one or more categories.

Thanks in advance.

http://www.biomedgate.com
****Portal to life****
Quote Reply
Re: Simple question about sql In reply to
yanzi:

I don't think you can do something like this from the Monitor.... you can only submit single statements... not conditionals and such.

To do this, you would need to write a perl script and run that...

dave

Quote Reply
Re: Simple question about sql In reply to
INSERT INTO Category (Name,Full_Name)
VALUES ('A', 'Foo/A'), ('B', 'Foo/B'), ... ('Z', 'Foo/Z');

would do the trick.

Cheers,

Alex

--
Gossamer Threads Inc.
Quote Reply
Re: Simple question about sql In reply to
Hi, Alex

Your SQL command works and will certainly save lot of time adding multiple similiar categories. However there is a small problem. All category added in this way will have FatherID of 0, no matter what full name is and whether tables have been repaired or not after excuting the SQL command. Though I can include FatherID in my SQL command. I wonder if there is other way of doing this without first looking for FatherID of the supercategoy into which subcats are going to be added, and including FatherID in SQL command.

Another small problem is that the same sql command doesn't work in Links NG's monitor. The error message is SQL syntax error (actually not).

Thanks,

Yanz

http://www.biomedgate.com
****Portal to life****
Quote Reply
Re: Simple question about sql In reply to
i was wondering about this, i was planning on writing a tiny (php sorry everyone) script to ask you to type in the parent id number to then create an A,B,C,D,E alphabar. I assume the only information a category needs before creation is

i) name
ii) path of directory
iii) parent id

i was going to make ii) from iii) automatically in the script.

anything else needed?

http://www.ASciFi.com/ - The Science Fiction Portal
Quote Reply
Re: Simple question about sql In reply to
oops.. i meant iii from ii.

so you type in /TV/Stargate/Fan_Fic/

and it then realises you want to create
/TV/Stargate/Fan_Fic/A
/TV/Stargate/Fan_Fic/B
/TV/Stargate/Fan_Fic/C

works out the id of /TV/Stargate/Fan_Fic for parent id and knows the paths for A,B,C

once done it would not be hard to have additonal often used categories like 1,2,3,4,5,6,7,8,9,0 as an option.

http://www.ASciFi.com/ - The Science Fiction Portal
Quote Reply
Re: Simple question about sql In reply to
Thanks.

I would also appreciate it very much if somebody could write a similar query for adding links in monitor box. Since for a link, category info and link info are stored in two tables, I am not sure how to deal with that. I may not care about providing a category ID to which links will be added.

Thank a lot!

Yanz

http://www.biomedgate.com
****Portal to life****
Quote Reply
Re: Simple question about sql In reply to
I would recommend reading documents at http://www.mysql.com to become familar with SQL commands.

Simple example:

Code:

INSERT INTO Links (Title,URL,Description) VALUES ('SomeTitle','SomeURL','SomeDescription');


Regards,

Eliot Lee
Quote Reply
Re: Simple question about sql In reply to
Thanks Eliot,

There is one problem with your query. It dosen't specify category value which should be inserted to another table.

Yanz

http://www.biomedgate.com
****Portal to life****
Quote Reply
Re: Simple question about sql In reply to
Well, it was an EXAMPLE! Did you thoroughly READ my REPLY???

In Reply To:

Simple example:


Simple means basic, rudimentary, etc.!

You include ALL the field names in the LINKS table in the first enclosed set of fields, then you add the actual CATEGORY value in the second enclosed set!

If you want a COMPLETE example of what you need to do, SEARCH the http://www.mysql.com for COMPLETE SQL commands that you can use!

Got it?????

Regards,

Eliot Lee