编程论坛's Archiver

gjw5299 发表于 2008-3-8 17:17

一条SQL语句的问题.在线等

select * from product,UserInfo where product.typeID=UserInfo.UserNum and product.spec=5000 order by usein,pid desc
这样错了吗?其中product,UserInfo 是表名,product.typeID字段和UserInfo.UserNum字段一样,但是这样查不出结果
但少了and product.spec=5000 如下
select * from product,UserInfo where product.typeID=UserInfo.UserNum order by usein,pid desc
就可以查出来,请高手指教一下

ヤ順祺冄繎ヤ 发表于 2008-3-8 20:18

没看出SQL有问题
会不会是Spec的类型与5000有问题的

lilan1221 发表于 2008-3-9 17:44

“select * from product,UserInfo where product.typeID=UserInfo.UserNum order by usein,pid desc”执行这条语句由你想要的答案吗?

huzi_2008 发表于 2008-3-11 10:55

用另一种方法试试,join  on

liuning 发表于 2008-3-30 15:10

应该 用连接  你着样 肯定有错误

nan42331599 发表于 2008-3-31 13:49

必须用内连接

shezhenhui1989 发表于 2008-3-31 16:26

对,用内联接试试

we921 发表于 2008-4-1 16:49

用内联连接

hebingbing 发表于 2008-4-1 19:48

你试试
select * from product,UserInfo where product.spec=5000 order by usein,pid desc
这样可以查处数据吗?
要是这样不行就是spec的类型和5000不配等的问题了……

页: [1]

Powered by Discuz! Archiver 6.1.0  © 2001-2007 Comsenz Inc.