PDA

View Full Version : a complex sql update



pkcidstudio
05-02-2007, 07:22 PM
The Error I am recieiving:
Error in query: UPDATE dw_eqpt_cat_main SET `sCat_Name` = 'KELLY' ( SELECT iItem_Id, iCat_Id FROM dw_eqpt_items WHERE `iCat_Id` = '1' AND `iItem_Id` = '690') LIMIT 1

It looks like it is processing the information correctly.

my query:


$sCat_Name= $_POST['sCat_Name'][$i];
$iCat_Id = $_POST['iCat_Id'][$i];
$iItem_Id = $_POST['id'][$i];

$update_sCat_Name = "UPDATE $tbl_name2
SET `sCat_Name` = '$sCat_Name' ( SELECT iItem_Id, iCat_Id
FROM $tbl_name
WHERE `iCat_Id` = '$iCat_Id' AND `iItem_Id` = '$iItem_Id') LIMIT 1";

pkcidstudio
05-03-2007, 06:57 PM
SOLVED
http://dev.mysql.com/doc/refman/5.0/en/update.html

UPDATE `Table A`,`Table B`
SET `Table A`.`text`=concat_ws('',`Table A`.`text`,`Table B`.`B-num`," from ",`Table B`.`date`,'/')
WHERE `Table A`.`A-num` = `Table B`.`A-num`

exipnos
05-05-2007, 02:40 PM
if you use mysql you have to remove
" FROM $tbl_name "
:)