I am running below query in Snowflake:
UPDATE PROVIDER_XO_SCORE_TABLE AS PXS
SET PXS.PROVIDER_ID = (SELECT P.PROVIDER_ID
FROM PROVIDER_TABLE P
WHERE PXS.XPI = P.XPI);
This query working fine in MySql but giving below error message in Snowflake.
SQL compilation error:
Unsupported subquery type cannot be evaluated
You can use the join-like syntax with UPDATE...FROM:
UPDATE PROVIDER_XO_SCORE_TABLE PXS
SET PROVIDER_ID = P.PROVIDER_ID
FROM PROVIDER_TABLE P
WHERE PXS.XPI = P.XPI;
Related
I am using redshift and have followed this from an example. But I get the error:
[42601] ERROR: syntax error at or near "INNER" Position:
UPDATE podcast_platform_episode_level
INNER JOIN podcast_country_codes
ON podcast_platform_episode_level.country = podcast_country_codes.country
SET podcast_platform_episode_level.country_label = podcast_country_codes.country_label
Try this
UPDATE podcast_platform_episode_level
SET country_label = podcast_country_codes.country_label
FROM podcast_country_codes
WHERE podcast_platform_episode_level.country = podcast_country_codes.country
I renamed a column to country_code in podcast_platform_episode_level to help avoid confusion. But still surpised this code below works when the code above does not
-- adds country_label data
UPDATE podcast_platform_episode_level
SET country_label = c.country_label
FROM podcast_country_codes c
WHERE c.country = country_code;
I am sure that you are used to this question but nonetheless I am having trouble with my SQL script. It is very frustrating.
When I execute the SQL against the SAP Hana database, I continuously receive this error:
Errors occurred while executing the SQL statement: SAP DBTech JDBC: [257]: sql syntax error: incorrect syntax near ")": line 14 col 35
Let me present the SQL concerned here:
SELECT
BKPF.BKTXT, BKPF.MONAT, BSEG.BELNR, BSEG.BUKRS, BSEG.DMBTR, BSEG.GJAHR, BSEG.MANDT, BSEG.PRCTR, BSEG.SAKNR, CEPCT.KTEXT, CEPCT.LTEXT, SKAT.MCOD1, SKAT.TXT20, SKAT.TXT50
FROM
SAPPR1.BSEG
INNER JOIN SAPPR1.BKPF ON BSEG.GJAHR = BKPF.GJAHR
INNER JOIN SAPPR1.CEPCT ON BSEG.PRCTR = CEPCT.PRCTR
INNER JOIN (SELECT
SAKNR, TXT20, TXT50, MCOD1
FROM
SAPPR1.SKAT
WHERE
SPRAS not LIKE '%[a-z0-9 .]%' ) AS SKAT_SUB ON BSEG.SAKNR = SKAT_SUB.SAKNR
WHERE
BKPF.MONAT = (SELECT Month('?')-1)
AND (BSEG.GJAHR = (SELECT Year('?')-1 HAVING Month('?')-1 < 4) OR BSEG.GJAHR = (SELECT Year('?') HAVING Month('?')-1 > 3))
AND BSEG.MANDT = ?
;
Unlike other DBMS HANA does not support selecting records out of nothing.
A SELECT without a FROM is not valid.
In order to create a single-row set one can use the DUMMY table.
SELECT current_date FROM DUMMY;
creates the single-row set with the result of the function expression.
Having said that, for comparisons a set is not required. Instead the function can be directly put into the expression:
WHERE
BKPF.MONAT = (MONTH(?)-1)
Also note that for string typed bind variables no quotation marks are required or allowed.
I have a database in access but recently moved to SQL server, and I have modified almost all queries but this one :
UPDATE Articulos_Auditoria
INNER JOIN Auditoria ON Articulos_Auditoria.CUD = Auditoria.CUD
SET Articulos_Auditoria.Cortado = 'True'
WHERE
(((CAST([Fecha] AS DATE)) = CAST(#Fecha AS DATE))
AND ((Auditoria.Terminal) = #term))
I am trying to convert it to SQL Server (since I changed DateValue to a CAST) but intellisense gives me a syntax error near 'INNER'
Can anyone give me some insight?
You have two errors:
You need to define the SET after the UPDATE TableName
You need to define a FROM clause
UPDATE Articulos_Auditoria
SET Cortado = 'True'
FROM Articulos_Auditoria
INNER JOIN Auditoria
ON Articulos_Auditoria.CUD = Auditoria.CUD
WHERE CAST([Fecha] as date)=CAST(#Fecha as date)
AND Auditoria.Terminal=#term
Use the from clause and table aliases:
UPDATE aa
SET Cortado = 'True'
FROM Articulos_Auditoria aa INNER JOIN
Auditoria a
ON aa.CUD = a.CUD
WHERE CAST([Fecha] as date) = CAST(#Fecha as date) AND (a.Terminal = #term)
i'm working on a request ,and i think i missed a clause because i having this error
ERROR at line 1:
ORA-00933: SQL command not properly ended
the request :
echo "update account_balances_t set credit_limit='51200' inner join account_t on account_t.poid_id0=account_balances_t.obj_id0 where access_code1 in (SELECT DISTINCT ACCESS_CODE1,REC_ID FROM ACCOUNT_T A, ACCOUNT_PRODUCTS_T AP WHERE A.STATUS != 10103 AND A.ACCESS_CODE1 IS NOT NULL AND A.POID_ID0 = AP.OBJ_ID0 AND AP.PRODUCT_OBJ_ID0 = (SELECT POID_ID0 FROM PRODUCT_T WHERE NAME = 'IEW - Europe Daily Plan 1')); "|sqlplus -s `whoami`/`whoami`#$ORACLE_SID
the error :
SELECT DISTINCT ACCESS_CODE1,REC_ID FROM ACCOUNT_T A, ACCOUNT_PRODUCTS_T AP WHERE A.STATUS != 10103 AND A.ACCESS_CODE1 IS NOT NULL AND A.POID_ID0 = AP.OBJ_ID0 AND AP.PRODUCT_OBJ_ID0 = (SELECT POID_ID0 FROM PRODUCT_T WHERE NAME = 'IEW - Europe Daily Plan 1'))
*
ERROR at line 1:
ORA-00933: SQL command not properly ended
You basically have this:
UPDATE account_balances_t
SET credit_limit='51200'
INNER JOIN account_t ON account_t.poid_id0=account_balances_t.obj_id0
WHERE access_code1 IN (...);
I can't find anything similar among the available syntax variations for UPDATE.
Also, you're attempting to match column access_code1 with a subquery that returns two columns.
UPDATE PEOPLE a
SET a.SURNAME = (
select b.SURNAME
from PEOPLE b
where b.NI.NO = a.NI_NUMBER
)
update account__balances_t set credit_limit='51200' inner join account_t on .....
Syntax is bad - oracle doesn't support 'inner join' here. Correct syntax is:
UPDATE table SET colum=expression [,column = expression ... ]
WHERE condition<br>
Read here: http://docs.oracle.com/cd/B19306_01/server.102/b14200/statements_10007.htm
I've this SQL statement:
UPDATE Movement_Item_Lots
SET Batch_Code = (SELECT WHSS.Batch_Code
FROM WH_Stock_Serials AS WHSS
WHERE WHSS.Item_Code = Movement_Item_Lots.Item_Code
AND WHSS.From_Distribution_Code = Movement_Item_Lots.Distribution_Code
)
it returns :
There was an error parsing the query.
[ Token line number = 2,Token line offset = 19,Token in error = SELECT ]
I know this is common issue in SQL Server CE that it can't do update from, any workaround for this issue ?
Change to sqlite, if possible, this sql would work... If not possible, you can always divide the statement in your program:
var <- SELECT WHSS.Batch_Code...
UPDATE .. SET Batch_Code = var