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='
相关问答:
大家帮忙看看这2个sql语句哪个查询的速度更快点。谢谢帮忙。比较着急。在做性能测试。
select * from
表A LEFT OUTER JOIN 表B ON (表A.id || ' ' =表B.id) ,表C , 表D, 表E
Where其他条件
select * ......
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jas ......
我要得到一个字符串如:
sdfk|||sgts
sdfsfd|||rgreg
wrfw|||sefw
就是要得到|||后面的字符串,有什么函数吗?怎么用呢?谢谢!
SQL code:
select
right(col,len(col)-charindex('|||',col)-2)
f ......
需求如下:
a表:
p_id status
1 0
2 0
b表
rec_id pid purchase_qty receive_qty flag
1 1 10 10 0
2 ......
题目:把“SC”表中“叶平”老师教的课的成绩都更改为此课程的平均成绩;
sql语句:
update SC set score=(SELECT avg(SC_2.score)
from SC SC_2
WHERE S ......