2010年11月16日星期二

[PerlChina] CSV的SQL语句中一张表不能出现两次

大家好,
 
有一张表,我需要多次关联,设了不同的别名,但是执行SQL的时候报错,大家有用过DBD-CSV的高手,帮我看看这是DBD CSV的限制还是SQL写的不对
 
SQL语句:
select c.husband,h.age,c.wife,w.age from couple c, people h, people w where c.husband = h.name and c.wife = w.name;
 
报错信息:
DBD::CSV::st execute failed: Error 2012 while reading file D:\Perl\people.csv: E
OF - End of data in parsing input stream at C:/strawberry/perl/site/lib/SQL/Stat
ement.pm line 813
 [for Statement "select c.husband,h.age,c.wife,w.age from couple c, people h, pe
ople w where c.husband = h.name and c.wife = w.name"] at csv.pl line 99.
 
以下SQL语句都可以正常执行:
 
select * from couple;

husband    |wife       |
========================
James      |Mary       |
Roger      |Lily       |
========================
Return 2 columns and 2 lines
 
select * from people;
 
name       |age        |
========================
Mary       |22         |
Lily       |26         |
Roger      |24         |
James      |30         |
========================
Return 2 columns and 4 lines
 
select c.husband,h.age from couple c, people h  where c.husband = h.name;

c.husband  |h.age      |
========================
James      |30         |
Roger      |24         |
========================
Return 2 columns and 2 lines
 
select c.wife,w.age from couple c, people w where c.wife = w.name;
 
c.wife     |w.age      |
========================
Mary       |22         |
Lily       |26         |
========================
Return 2 columns and 2 lines
 
祝好
家强

没有评论: