Need help wtih SQL
But I have no time to write it down... I will sketch my problem, and hopefully get an answer (I've started this blog in the morning, and now I need to close it, cause I have to leave).
Imagine I have following table (a triple store):
How do I make a query that returns me the following table:
The problems are the default value in the middle lower cell. The rest works (as maybe seen in the Semantic Mediawiki code, file includes/SMW_InlineQueries.php -- note that the CVS is not up to date for now, because SourceForge's CVS is down for days!)
It should work in general, with as many columns as I like on the answer table (based on the predicates in the first one).
Oh, and if you solved this -- or have an idea -- it would be nice if it worked with MySQL 4.0, i.e. without Subqueries.
Any ideas?
Imagine I have following table (a triple store):
| Subject | Predicate | Object |
|---|---|---|
| Adam | yahoo im | adam@net |
| Adam | skype | adam |
| Berta | skype | berta |
| Subject | o1 | o2 |
|---|---|---|
| Adam | adam@net | adam |
| Berta | - | berta |
It should work in general, with as many columns as I like on the answer table (based on the predicates in the first one).
Oh, and if you solved this -- or have an idea -- it would be nice if it worked with MySQL 4.0, i.e. without Subqueries.
Any ideas?


7 Comments:
you can't do this for the generic case without using dynamic sql or procedures or some other non-relational paradigm.
ask yourself: do you really *want* to do this anyway? Why? Why not convert between a relational pairwise representation of a matrix and a matrix data structure out of SQL?
This can be done with LEFT JOINs in a single query. The ARC store does it, although I still have to add support for expressions which would allow adding "(?p1 != ?p2) && (?p2 != ?p3)".
Something similar to
[[
SELECT T1.s AS s, T1.o AS o1, T2.o AS o2
FROM triple T1
LEFT JOIN triple T2 ON
(
T2.s=T1.s AND NOT (T2.p=T1.p)
)
]]
should work for the 2-col example (there won't be NULL values in the first column (o1), though, as o1 is made mandatory in the query).
HTH,
Benjamin
Consider the use of OpenLink Virtuoso :) You will be able to write write SPARQL select instead of SQL select :) What's important, you will be able to write SPARQL select in almost any place where you can write SQL select. Say, SPARQL select can be a subexpression of a plain SQL select.
Re. the original question. Yes, you will need a LEFT OUTER JOIN.
Thanks Best Regards
mirc
mirç
mırc
mırç
mircturk
turkmirc
turkiyemirc
mircturkiye
mirch
mırch
mirc indir
mirc yükle
mirc yukle
mırc indir
mırc yukle
mirc turkiye
turkiye mirc
turk mirc
mirc turk
türkçe mirc
türkce mirc
türkçe mırc
turkce mirc
turkçe mirc
turkçe mırc
turkce mirc
mirc chat
mirc sohbet
mirc ara
muhabbet
chat
blog
muhabbet
forum
forum
turkiyeforum
türk forum
mirc
mircturk
turkmirc
mirc indir
sohbet
chat
bedava sohbet
turksohbet
turkiye sohbet
sohbet odaları
bedava chat
chat odaları
türk chat
türkiye chat
turkada
turkmirc
mirc inndir
karar
仓储笼
仓库笼
折叠式仓储笼
托盘
钢托盘
堆垛架
钢制料箱
物流台车
手推车
仓储笼
仓库笼
折叠式仓储笼
托盘
钢托盘
堆垛架
巧固架
钢制料箱
物流台车
载物台车
手推车
手推车
轻型货架
角钢货架
中型货架
次重型货架
重型货架
横梁式货架
托盘式货架
贯通式货架
通廊式货架
阁楼货架
钢平台
精品货架
展示货架
悬臂式货架
抽屉式货架
模具货架
辊轮式货架
流利式货架
移动式货架
密集架
网片
隔离网
护栏
仓储笼
仓库笼
折叠式仓储笼
钢托盘
钢制托盘
置物柜
置物架
挂板架
物料整理架
单挂钩
直挂钩
螺丝刀架
扳手架
工作台
工作桌
线棒货架
输送辊道
辊道输送机
不锈钢制品
不锈钢推车
仓储笼
钢托盘
塑料托盘
钢制料箱
物流台车
堆垛架
静音手推车
手动液压托盘搬运车
登高车
手动堆高车
平台车
仓储货架
仓库货架
库房货架
南京货架
中型货架
横梁式货架
钢制托盘
塑料托盘
纸托盘
折叠式仓储笼
仓库笼
钢制料箱
工具柜
工作台
手动液压托盘搬运车
手动液压堆高车
仓库货架
中量A型货架
仓储货架
横梁式货架
货位式货架
托盘
塑料托盘
钢制托盘
纸托盘
仓储笼
折叠式仓储笼
仓库笼
蝴蝶笼
储物笼
手动液压托盘搬运车
手动液压堆高车
仓储货架
仓库货架
库房货架
南京货架
中型货架
横梁式货架
钢制托盘
塑料托盘
纸托盘
折叠式仓储笼
仓库笼
钢制料箱
工具柜
工作台
手动液压托盘搬运车
手动液压堆高车
仓库货架
中量A型货架
仓储货架
中量B型货架
库房货架
横梁式货架
货位式货架
钢托盘
钢制托盘
铁托盘
栈板
塑料托盘
塑料栈板
纸托盘
栈板
仓储笼
仓库笼
折叠式仓储笼
蝴蝶笼
储物笼
钢制料箱
钢质周转箱
网格式料箱
手动液压托盘搬运车
托盘搬运车
货架
仓储货架
仓库货架
库房货架
南京货架
上海货架
北京货架
轻型货架
中型货架
搁板式货架
重型货架
横梁式货架
托盘货架
托盘
木托盘
纸托盘
木塑托盘
托盘
钢托盘
塑料托盘
钢制托盘
仓储笼
仓库笼
折叠式仓储笼
手推车
静音手推车
铁板手推车
物料架
整理架
挂板架
钢制料箱
钢制周转箱
网格式料箱
料箱
手动液压托盘搬运车
电动托盘搬运车
手动液压堆高车
半电动堆高车
手动叉车
塑料周转箱
物流箱
塑料化工桶
塑料卡板箱
工具柜
上海工具柜
南京工具柜
抽屉柜
工作台
工作桌
南京工作台
上海工作台
刀具车
刀具柜
刀具架
刀具座
仓储货架
仓库货架
库房货架
南京货架
中型货架
横梁式货架
钢制托盘
塑料托盘
纸托盘
折叠式仓储笼
仓库笼
钢制料箱
工具柜
工作台
手动液压托盘搬运车
手动液压堆高车
仓库货架
中量A型货架
仓储货架
中量B型货架
库房货架
横梁式货架
货位式货架
钢托盘
钢制托盘
铁托盘
栈板
塑料托盘
塑料栈板
纸托盘
栈板
仓储笼
仓库笼
折叠式仓储笼
蝴蝶笼
储物笼
钢制料箱
钢质周转箱
网格式料箱
手动液压托盘搬运车
托盘搬运车
仓储笼
仓库笼
折叠式仓储笼
仓储笼
仓库笼
折叠式仓储笼
折叠仓储笼
仓储笼
仓库笼
折叠式仓储笼
折叠仓储笼
仓储笼
仓库笼
折叠式仓储笼
折叠仓储笼
仓储笼
仓储笼
仓库笼
仓库笼
折叠式仓储笼
折叠式仓储笼
折叠仓储笼
折叠仓储笼
仓储笼
仓库笼
折叠式仓储笼
折叠仓储笼
仓储笼
仓库笼
折叠式仓储笼
折叠仓储笼
仓储笼
仓库笼
折叠式仓储笼
仓储笼
仓储笼
仓储笼
仓库笼
折叠式仓储笼
托盘
托盘
托盘
托盘
钢托盘
钢制托盘
塑料托盘
塑料托盘
塑料托盘
托盘
塑料托盘
钢托盘
钢制托盘
铁托盘
托盘
钢托盘
铁托盘
钢制托盘
塑料托盘
托盘
钢托盘
铁托盘
钢制托盘
塑料托盘
托盘
托盘
钢托盘
钢托盘
铁托盘
铁托盘
钢制托盘
钢制托盘
塑料托盘
塑料托盘
托盘
钢托盘
铁托盘
钢制托盘
塑料托盘
托盘
钢托盘
铁托盘
钢制托盘
塑料托盘
托盘
钢托盘
铁托盘
钢制托盘
塑料托盘
托盘
托盘
托盘
钢托盘
钢制托盘
托盘
塑料托盘
货架
仓储货架
仓库货架
货架
仓储货架
仓库货架
货架厂
货架
仓储货架
仓库货架
货架厂
货架公司
货架
仓储货架
仓库货架
货架厂
货架公司
货架
货架
仓储货架
仓储货架
仓库货架
仓库货架
货架厂
货架厂
货架公司
货架公司
货架
货架
仓储货架
仓储货架
仓库货架
仓库货架
货架厂
货架厂
货架公司
货架公司
货架
货架
货架
仓储货架
仓储货架
仓储货架
仓库货架
仓库货架
仓库货架
货架厂
货架厂
货架厂
货架公司
货架公司
货架公司
货架
货架
货架
仓储货架
仓储货架
仓储货架
仓库货架
仓库货架
货架厂
货架厂
货架公司
货架公司
货架
货架
货架
货架
轻量型货架
角钢货架
货架
中量型货架
次重型货架
货位式货架
重量型货架
横梁式货架
仓储货架
阁楼式货架
钢平台
仓储货架
悬臂式货架
仓储货架
贯通式货架
通廊式货架
驶入式货架
仓库货架
库房货架
抽屉式货架
模具货架
仓库货架
库房货架
汽车4S店货架
汽配库货架
货架厂
货架公司
南京货架
上海货架
无锡货架
苏州货架
货架厂
货架公司
北京货架
天津货架
沈阳货架
大连货架
货架厂
货架公司
广州货架
深圳货架
宁波货架
杭州货架
南京货架
货架公司
货架厂
仓库货架
仓储货架
货架
货架
Thanks Best Regards
mirc
mırc
mırç
mircturk
turkmirc
mirc indir
mırc indir
mirç indir
mirc yükle
mırc yükle
mirc yukle
mırc yukle
mirch
mırch
mirc turk
turk mirc
mırc turk
mircada
mircturkiye
muhabbet
mirc sohbet
mırc sohbet
mirc chat
mırc chat
mırc ındır
mirc ındır
türkçe mirc
turkce mirc
turkçe mırc
turkce mırc
oper mirc
Thanks Best Regards
mirc
mırc
mırç
mircturk
turkmirc
mirc indir
mırc indir
mirç indir
mirc yükle
mırc yükle
mirc yukle
mırc yukle
mirch
mırch
mirc turk
turk mirc
mırc turk
mircada
mircturkiye
muhabbet
mirc sohbet
mırc sohbet
mirc chat
mırc chat
mırc ındır
mirc ındır
türkçe mirc
turkce mirc
turkçe mırc
turkce mırc
oper mirc
Post a Comment
Links to this post:
Create a Link
<< Home