Comments on: SIC Codes – SQL for Database Import http://www.terminally-incoherent.com/blog/2009/01/08/sic-codes-sql-for-database-import/ I will not fix your computer. Tue, 04 Aug 2020 22:34:33 +0000 hourly 1 https://wordpress.org/?v=4.7.26 By: John http://www.terminally-incoherent.com/blog/2009/01/08/sic-codes-sql-for-database-import/#comment-108203 Thu, 05 Jun 2014 23:12:22 +0000 http://www.terminally-incoherent.com/blog/2009/01/08/sic-codes-sql-for-database-import/#comment-108203

Nice but the SIC data is hierarchical and the schema you defined makes it hard to find parent and child entries.
This should be more sth like:
CREATE TABLE `sic_code` (
`code` varchar(32) NOT NULL DEFAULT ”,
`label` varchar(256) DEFAULT NULL,
`parent_code` varchar(32) DEFAULT NULL,
`level` int(11) DEFAULT NULL
) DEFAULT CHARSET=utf8;

INSERT INTO `sic_code` (`code`,`label`,`parent_code`,`level`)
VALUES
(‘D’,’MANUFACTURING’,NULL,0),
(‘I’,’SERVICES’,NULL,0),
(‘H’,’FINANCE, INSURANCE, AND REAL ESTATE’,NULL,0),
(‘F’,’WHOLESALE TRADE’,NULL,0),
(‘E’,’TRANSPORTATION, COMMUNICATIONS, ELECTRIC, GAS, AND SANITARY SERVICES’,NULL,0),
(‘J’,’PUBLIC ADMINISTRATION’,NULL,0),
(‘3199′,’Leather goods, not elsewhere classified’,’319′,3),
(‘478′,’Miscellaneous services incidental to transportation’,’47’,2),
(‘473′,’Arrangement of transportation of freight and cargo’,’47’,2),
(‘474′,’Rental of railroad cars’,’47’,2),
(‘8399′,’Social services, not elsewhere classified’,’8

Reply  |  Quote
]]>
By: UngaMan http://www.terminally-incoherent.com/blog/2009/01/08/sic-codes-sql-for-database-import/#comment-13034 Fri, 21 Aug 2009 21:44:09 +0000 http://www.terminally-incoherent.com/blog/2009/01/08/sic-codes-sql-for-database-import/#comment-13034

Pretty neat solution!

Thanks! :)

Reply  |  Quote
]]>
By: Jonah Korbes http://www.terminally-incoherent.com/blog/2009/01/08/sic-codes-sql-for-database-import/#comment-12592 Thu, 18 Jun 2009 18:05:19 +0000 http://www.terminally-incoherent.com/blog/2009/01/08/sic-codes-sql-for-database-import/#comment-12592

Using your ready-made SIC code SQL. Thanks — this will save me a bit of time!

Reply  |  Quote
]]>
By: Alex http://www.terminally-incoherent.com/blog/2009/01/08/sic-codes-sql-for-database-import/#comment-11458 Fri, 06 Feb 2009 14:46:41 +0000 http://www.terminally-incoherent.com/blog/2009/01/08/sic-codes-sql-for-database-import/#comment-11458

Glad I could help! :) Thanks again, this made a report I was writing much easier!

Reply  |  Quote
]]>
By: Luke Maciak http://www.terminally-incoherent.com/blog/2009/01/08/sic-codes-sql-for-database-import/#comment-11457 Fri, 06 Feb 2009 14:11:25 +0000 http://www.terminally-incoherent.com/blog/2009/01/08/sic-codes-sql-for-database-import/#comment-11457

@Alex: Ah, that what it was then – some of the statements failed, but I didn’t notice and/or care when I imported it.

Then I read your post literally like 5 minutes after reading the bug report about missing values on the test system and I was like “aw, crap!”. :)

It shall be easy to fix now. Thanks!

Reply  |  Quote
]]>
By: Alex http://www.terminally-incoherent.com/blog/2009/01/08/sic-codes-sql-for-database-import/#comment-11456 Fri, 06 Feb 2009 13:44:45 +0000 http://www.terminally-incoherent.com/blog/2009/01/08/sic-codes-sql-for-database-import/#comment-11456

Hey Luke,

That’s strange, I just checked my DB and I have all the values, including between 23xx and 35xx. I did have to sanitize the SQL file a bit; you had semicolons in the `description` values which were throwing things off. I have an updated SQL file with all the quotes sanitized which ran without any errors; if you want I’ll email it to you, just let me know and leave me your email address (mine is alex@imperialtextile.com.

Reply  |  Quote
]]>
By: Luke Maciak http://www.terminally-incoherent.com/blog/2009/01/08/sic-codes-sql-for-database-import/#comment-11454 Thu, 05 Feb 2009 20:45:21 +0000 http://www.terminally-incoherent.com/blog/2009/01/08/sic-codes-sql-for-database-import/#comment-11454

@Alex: Btw, a recent ticket in my bug tracking system tells me that list is incomplete. It’s missing entries between 23xx and 35xx codes.

I shall update it here once I get to it at work. Must clear all the stuff that is marked critical and omg-the-sky-is-falling first.

Reply  |  Quote
]]>
By: Alex http://www.terminally-incoherent.com/blog/2009/01/08/sic-codes-sql-for-database-import/#comment-11453 Thu, 05 Feb 2009 20:37:38 +0000 http://www.terminally-incoherent.com/blog/2009/01/08/sic-codes-sql-for-database-import/#comment-11453

Hey… I have been searching for just this kind of file! I was hoping at best for TXT or CSV but to find the SQL is ideal so thank you very much!

Reply  |  Quote
]]>
By: Luke Maciak http://www.terminally-incoherent.com/blog/2009/01/08/sic-codes-sql-for-database-import/#comment-11231 Tue, 13 Jan 2009 20:03:31 +0000 http://www.terminally-incoherent.com/blog/2009/01/08/sic-codes-sql-for-database-import/#comment-11231

@Jaba: Ah, yes. The code highlighting plugin actually escapes all the HTML entities automatically. :)

And yeah, I’m somewhat familiar with macros. The beautiful thing about lisp is that it’s code is expressed in therms of it’s data structures. So data can be code, and code can be data, which introduces a mind boggling level of flexibility into the language.

Thanks for the examples. I will have to go over them slowly again later. :)

Reply  |  Quote
]]>
By: Jaba http://www.terminally-incoherent.com/blog/2009/01/08/sic-codes-sql-for-database-import/#comment-11227 Tue, 13 Jan 2009 09:31:06 +0000 http://www.terminally-incoherent.com/blog/2009/01/08/sic-codes-sql-for-database-import/#comment-11227

mmm let me re-write the end of the last pps:
with pre lang=”lisp” plugin, the & character gets represented as:

 & 
Reply  |  Quote
]]>