sql查询中的笛卡尔积 - c# [英] cartesian product in sql query - c#

查看:129
本文介绍了sql查询中的笛卡尔积 - c#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好。



我在C#中遇到sql查询问题:(。



这里是代码:



Hello guys.

I have a problem with the sql query in C# :(.

here is the code:

dts.Tables.Clear();
           
SqlDataAdapter da = new SqlDataAdapter("SELECT t.Date, t.Barcode, t.Name, t.Quantity, d.BuyPrice, t.SellPrice FROM tblSales t, tblMagazine d WHERE t.Date BETWEEN '" + DateTimePicker1.Value + "' AND '" + DateTimePicker2.Value + "'", con);

da.Fill(dts);

dataGridView1.DataSource = dts.Tables[0];





它给了我笛卡尔积或类似的东西....因为当我点击按钮(有这个代码)它向我展示了比表Sales中更多的表格。



有什么问题?有人可以帮我吗



It gives me cartesian product or something like that.... because when I click the button (that has this code) it shows me more tables than I have in the table Sales.

What is the problem ?? Can someone help me

推荐答案

tblSales tblMagazine 没有共同点...你对笛卡儿是正确的;



销售与杂志之间的联系是什么,因为这个缺失。
tblSales and tblMagazine don''t have something in common... you''re right about the cartesian;

What''s the link between Sales and Magazine, due this one''s missing.


这篇关于sql查询中的笛卡尔积 - c#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆