易截截图软件、单文件、免安装、纯绿色、仅160KB

sql语句奇怪问题

我的sql语句如下:

select a.productname,a.sell_price,b.id from umc_product a left join umc_product_image b on a.id=b.id where a.id='1034';

把结果放在个$arr里,这时$arr[0]有值,$arr[1]有值,但$arr[2]里没值,用$arr['id']也拿不到。

但是sql语句改到如下,$arr[2]里就有值了。

select a.productname,a.sell_pricea.id from umc_product a left join umc_product_image b on a.id=b.id where a.id='1034';

也就是拿不到b表中的字段。

这是什么原因?
a.id=b.id  没有匹配的记录,不用奇怪的

select a.productname,a.sell_pricea.id from umc_product a left join umc_product_image b on a.id=b.id where a.id='1034';
这句明显是错误的a.sell_pricea.id

不可能,在数据库执行是有记录的

而且如果没记录,那a.id也出不来

select a.productname,a.sell_price,a.id from umc_product a left join umc_product_image b on a.id=b.id where a.id='1034'

打字打错了

PHP code:

select b.productname,b.sell_price,a.id from umc_product_image a left join umc_product b on a.id=b.id where b.id='1034';

改成这样试试

用的是left join ,umc_product_image 有没有纪录跟a.id是没有关系的

select * from umc_product_image where id='1034';看有没有记录?

select * from umc_product_image where id='


相关问答:

SQL语句效率问题 - 其他数据库开发 / 其他数据库

大家帮忙看看这2个sql语句哪个查询的速度更快点。谢谢帮忙。比较着急。在做性能测试。
select * from
  表A LEFT OUTER JOIN 表B ON (表A.id || ' ' =表B.id) ,表C , 表D, 表E
Where其他条件
select * ......

jsp链接sql2000的疑问?



type Exception report


message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jas ......

sql 截取字符串

我要得到一个字符串如:
sdfk|||sgts
sdfsfd|||rgreg
wrfw|||sefw
就是要得到|||后面的字符串,有什么函数吗?怎么用呢?谢谢!
SQL code:
select
right(col,len(col)-charindex('|||',col)-2)
f ......

求一sql【谢谢】 - MS-SQL Server / 基础类

需求如下:
a表:
 p_id status  
  1 0
  2 0
b表
rec_id pid purchase_qty receive_qty flag
1 1 10 10 0
2 ......

一条sql查询语句

题目:把“SC”表中“叶平”老师教的课的成绩都更改为此课程的平均成绩; 
sql语句:
  update SC set score=(SELECT avg(SC_2.score)  
  from SC SC_2  
  WHERE S ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号