内部sql语句中的条件不起作用 [英] The condition in inner sql statement is not working

查看:87
本文介绍了内部sql语句中的条件不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




以下语句假设显示的广告与Cookie位置相同并且正在运行,但条件批准其无法正常运行,因为所有用户的值均为批准列Y或N他们的广告出现在哪里只有Y值的用户出现我试图从

Hi
The below statement suppose to show the ads which is equal cookie Location and that is working but the condition approv its not working as all user whose have value into approv column Y or N their ads is appear where should only users whith Y value appears i tried also to change from

WHERE IUS.[approv]='Y'

改为

And IUS.[approv]='Y'

但问题仍然存在



but the problem still exist

string HPAdsFQuery = @"SELECT AD.[AdsID], AD.[Country], AD.[State], AD.[City], AD.[AdsTit], SUBSTRING([AD.AdsDesc],1,50) as AD.AdsDesc,
            AD.[AdsPrice], AD.[Section], AD.[Category], AD.[Img1], AD.[AdsDate], IUS.[approv] FROM [ads] as AD JOIN UserInfo as IUS ON  AD.[Country] = @Location WHERE IUS.[approv]='Y' ORDER BY AD.[AdsDate] DESC";

推荐答案

当您将两个表连接在一起时,您必须指定两个表中的哪些字段参与连接。



您还没有说过UserInfo中的哪个字段应该加入[AD]
When you join two tables together you have to specify which fields in both tables are participating in the join.

You haven't said which field in UserInfo should be joined to [AD]


这篇关于内部sql语句中的条件不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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