作者ji3g4al6al6 (毛毛)
看板Database
标题[SQL ] 多表单选取
时间Fri Jun 4 23:03:32 2010
我使用的是MySQL 5.1
update droplist set item =
( select armor. name, etcitem. name, weapon. name
from armor, etcitem, weapon
where droplist. itemId = armor. item_id
or droplist. itemId = etcitem. item_id
or droplist. itemId = weapon. item_id )
我想写的是我想在droplist这个表单的item栏位
填入armor etcitem weapon这三个表单的name所对应的值
附上查询讯息:
[Err] 1241 - Operand should contain 1 column(s)
如果单一droplist对三个表单其中一个的话
分别执行会把上一个结果洗掉,如下写法
update droplist set item =
( select armor. name from armor where armor. item_id = droplist. item_id );
update droplist set item =
( select etcitem. name from etcitem where etcitem. item_id = droplist. item_id );;
update droplist set item =
( select weapon. name from weapon where weapon. item_id = droplist. item_id )
有什麽写法可以同时选取三个表单?
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 220.134.158.33
※ 编辑: ji3g4al6al6 来自: 220.134.158.33 (06/04 23:13)
1F:推 sidetalker:select armor.name+','+etcitem.name+','+weapon.name 07/06 18:26
2F:推 sidetalker:where那边的or通通改成and,而且要确定各只有一笔符合 07/06 18:34