我需要从四个表中选择仅基于一个的数据。选择多个具有相同ID的表格
在我的'计算'表中,我有我需要的所有记录。
但我需要检索每个记录一些其他的信息,从“程序”,“术语”和“进口”表。
'计算'有ID从'程序'。
但是,从达到创纪录的“进口”,我需要加入“项目”表,因为“项目”从具有ID “程序”和“进口”。
'term'有ID从'进口'。
所以,我尝试这样做:
select c.date,
p.name,
c.name1,
c.name2,
t.date,
i.version,
c.price1,
c.price2,
c.price3
from calculated c, programs p, term t, imported i, item it
where c.programs_id = p.programs_id
and c.programs_id = it.programs_id
and it.imported_id = i.imported_id
and i.term_id = t.term_id;
但是,当我使用COUNT(*)“计算”,我得到的记录30K,并从我的SELECT语句中我获得超过130个百万记录。
我在做什么错?
我应该怎么做才能工作?
感谢Koroed的帮助,但今天我被告知不再需要使用这个sql语句。那时我能够成功检索数据。谢谢大家的帮助。我很感激。 – LuizFranco 2013-03-01 21:38:12