注册 登录
编程论坛 MySQL论坛

求高手请教 一个很难的查询问题

xiaodong84 发布于 2012-07-02 09:51, 2030 次点击
现在有两个表   表的结构分别如下
contact(表)字段 id  mall_id(商家id)  log_new_name(商家logo)  

photos(表) 字段 id  mall_id(商家id)  pic(商家图片)  is(当is=1时  这条记录的中pic  作为logo)

其中contact mall_id  等于 photos  mall_id

现在问题是

当contact 中的log_new_name 为空值时 查找photos 表中的pic的值 同时is的值为1

该怎么写 各位大侠  恳求呀
2 回复
#2
java小蚂蚁2013-08-17 13:54
一个高级子查询,你多套几层应该就没有问题了
#3
3037709572013-08-19 13:55
select PC.pic from (select * from photos as P,contact as C where P.mall_id=C.mall_id) as PC
where (PC.log_new_name is null or len(PC.log_new_name)=0) and PC.is=1
1