Mysql - 如果不为空则选择不同
我需要让我的客户可以选择在不同类别中发布一些具有相同名称的帖子。 CMS 已关闭,我无法添加更多字段... 有一个备用字段,我可以用它来识别相同的帖子,但我不会加载精确帖子的情况(在我的情况下帖子是图像)。
所以我认为我的客户可以为所有相同的帖子指定相同的“字段”。
问题是该字段的默认值为空。如果我使用不同的,则只有一个结果来自所有不相同的帖子(默认情况下所有帖子= null)...
是否有一种方法可以选择不同的“字段”(如果不为空)?
我尝试对上述内容进行查找和反复试验,但它对我不起作用...
查询本身非常简单...
SELECT id,introtext,publish_up,publish_down
from #__content
WHERE catid IN(936,937,940,959,972,988,991) AND state = 1
AND ( publish_up = "0000-00-00 00:00:00" OR publish_up <= "2011-10-30 12:12:59" )
AND ( publish_down = "0000-00-00 00:00:00" OR publish_down >= "2011-10-30 12:12:59" )
--removed duplicated query
将不胜感激任何线索或方向... 谢谢! 亚尼潘
I need to give my client the option to publish some posts with same name in different categories. the CMS is closed and I can't add anymore fields...
There is a spare field which I can use to identify posts as identical, but I don't won't a situation where to exact posts will load (posts in my case are images).
So I figured my client can specify identical "field" for all identical posts.
The problem is that the default for the field is null. if i'll use distinct, only one result will come from all the non-identical posts (all of them by default = null)...
Is there a way to select distinct "field" if not null?
I tried looking and trial and error with the above but it didn't work for me...
The query itself is quite simple...
SELECT id,introtext,publish_up,publish_down
from #__content
WHERE catid IN(936,937,940,959,972,988,991) AND state = 1
AND ( publish_up = "0000-00-00 00:00:00" OR publish_up <= "2011-10-30 12:12:59" )
AND ( publish_down = "0000-00-00 00:00:00" OR publish_down >= "2011-10-30 12:12:59" )
--removed duplicated query
Will appreciate any clue or directions...
Thanks!
Yanipan
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
哪个字段默认为 NULL?我将其命名为 X,您可以相应地更改它:
我希望我做对了!
Which field is by default NULL? I'll just name it X and you can change it accordingly:
I hope I got it right!