-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Parse a column association into tokens for Join Strategy?
PostPosted: Fri Oct 24, 2008 7:10 pm 
Newbie

Joined: Fri Oct 24, 2008 7:02 pm
Posts: 4
Working with a legacy table.

Can a column be parsed into tokens before the join or select is made to fetch the association (based on said tokens)?

If we have a STATUS column = 07000101, that corresponds to the IH International Hub row in the lookup table. See how the 07 00 01 01 line up with the Type L1, L2, and L3 columns?

This seems to be a Join Strategy we want to introduce. Did not find anything out there, or know the right terms to use while searching for it.


mysql> select * from lookups where type = 7;
+------+----+----+----+------+-----------------------+--------------------------------------+
| Type | L1 | L2 | L3 | Name | Description |
+------+----+----+----+------+-----------------------+--------------------------------------+
| 7 | 0 | 0 | 0 | NULL | Source |
| 7 | 0 | 1 | 0 | NULL | Hub |
| 7 | 0 | 1 | 1 | IH | International Hub |
| 7 | 0 | 1 | 2 | EWRH | EWRH Airport Hub |
| 7 | 0 | 1 | 3 | OAKH | OAKH Airport Hub |


Thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 05, 2008 1:41 am 
Newbie

Joined: Fri Oct 24, 2008 7:02 pm
Posts: 4
Resolution was to create a view that concatenates the rows:

the interesting part...

VIEW `lookups_view` AS select `lookups`.`Type` AS `Type`,`lookups`.`L1` AS `L1`,`lookups`.`L2` AS `L2`,`lookups`.`L3` AS `L3`,`lookups`.`Name` AS `Name`,`lookups`.`Description` AS `Description`,`lookups`.`rowguid` AS `rowguid`,((((`lookups`.`Type` * 1000000) + (`lookups`.`L1` * 10000)) + (`lookups`.`L2` * 100)) + `lookups`.`L3`) AS `lookup_value` from `lookups`


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 05, 2008 1:42 am 
Newbie

Joined: Fri Oct 24, 2008 7:02 pm
Posts: 4
Resolution was to create a view that concatenates the level columns into one new column, lookup_value:

the interesting part...
Code:
VIEW `lookups_view` AS select `lookups`.`Type` AS `Type`,`lookups`.`L1` AS `L1`,`lookups`.`L2` AS `L2`,`lookups`.`L3` AS `L3`,`lookups`.`Name` AS `Name`,`lookups`.`Description` AS `Description`,`lookups`.`rowguid` AS `rowguid`,((((`lookups`.`Type` * 1000000) + (`lookups`.`L1` * 10000)) + (`lookups`.`L2` * 100)) + `lookups`.`L3`) AS `lookup_value` from `lookups`


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.