SQL Syntax Error with WHERE Clause - sql

INSERT INTO Census_Demographics (median_rooms)
VALUES ('8')
WHERE match_code = 'G06000104002001';
Above statement is throwing the follow error and I haven't been able to figure it out.
You have an error in your SQL syntax; check the manual that
corresponds to your MariaDB server version for the right syntax to
use near 'WHERE match_code = 'G06000104002001'' at line 1 Query is :
INSERT INTO Census_Demographics (median_rooms) VALUES ('8') WHERE
match_code = 'G06000104002001'; Error Code: 1064

You probably intend update:
update Census_Demographics
set median_rooms = 8
where match_code = 'G06000104002001';

Related

Error in SQL statement: ParseException: mismatched input 'FROM' expecting from Databricks SQL

I am trying to update the columns based on other table data but receiving the below error
Trying to execute in Databricks
Error in SQL statement: ParseException:
mismatched input 'FROM' expecting {<EOF>, ';'}(line 8, pos 0)
== SQL ==
UPDATE
rd
SET
rd.transaction_date = olc.transaction_date,
rd.store_number = olc.store_number,
rd.terminal_number = olc.terminal_id,
rd.sequence_number = olc.transaction_number
FROM delta.`/reservation_detail_olc` rd
^^^
UPDATE
rd
SET
rd.transaction_date = olc.transaction_date,
rd.store_number = olc.store_number,
rd.terminal_number = olc.terminal_id,
rd.sequence_number = olc.transaction_number
FROM delta.`reservation_detai` rd
inner JOIN
delta.`order_line` olc
ON rd1.confirmation_number =olc.res_confirmation_number
WHERE rd.confirmation_number =olc.res_confirmation_number
The syntax used in Databricks SQL guide for update command does not have FROM clauses. They do not support it.

Update multiple columns from a sub query

UPDATE PINPOINT_SUPPLEMENT
SET (ATTACHMENT_VALUE,ATTACHMENT_TYPE) = (
SELECT key,'file'
FROM PINPOINT_DOCUMENT
WHERE PINPOINT_SUPPLEMENT.ATTACHMENT_VALUE::integer = PINPOINT_DOCUMENT.DOCUMENT_ID
)
WHERE ATTACHMENT_VALUE IS NULL
Getting Error when i execute this query
ERROR: syntax error at or near "SELECT"
LINE 3: SELECT key,'file
update PINPOINT_SUPPLEMENT
set
ATTACHMENT_VALUE = PINPOINT_DOCUMENT.key,
ATTACHMENT_TYPE = 'file'
from PINPOINT_DOCUMENT
where
PINPOINT_SUPPLEMENT.ATTACHMENT_VALUE::integer = PINPOINT_DOCUMENT.DOCUMENT_ID
and PINPOINT_SUPPLEMENT.ATTACHMENT_VALUE IS NULL
or
update PINPOINT_SUPPLEMENT
set
(ATTACHMENT_VALUE,ATTACHMENT_TYPE) = (PINPOINT_DOCUMENT.key, 'file')
from PINPOINT_DOCUMENT
where
PINPOINT_SUPPLEMENT.ATTACHMENT_VALUE::integer = PINPOINT_DOCUMENT.DOCUMENT_ID
and PINPOINT_SUPPLEMENT.ATTACHMENT_VALUE IS NULL
Support for updating tuples was introduced in Postgres 9.5, so you can't use that syntax with your version.
But as the second value is a constant I don't see a reason to use that syntax to begin with:
UPDATE PINPOINT_SUPPLEMENT
SET ATTACHMENT_VALUE = (SELECT "key"
FROM PINPOINT_DOCUMENT
WHERE PINPOINT_SUPPLEMENT.ATTACHMENT_VALUE::integer = PINPOINT_DOCUMENT.DOCUMENT_ID),
ATTACHMENT_TYPE = 'file'
WHERE ATTACHMENT_VALUE IS NULL
Note, that the sub-query might result in an error if there is more than one ATTACHMENT_VALUE for a document_id!

sybase script don't understand trouble

I 'm not a regular of Sybase ASE.
Tring to make a script to add line into a tempory table.
sybase version 12.5.4
BEGIN
declare and init variable
--boucle
select * into #parTemp from Parution where 1=2
WHILE #dateCourante <= #dateFin
BEGIN
select #dpart1=datepart(mm,#dateCourante)
select #dpart2=datepart(dd,#dateCourante)
select #dpart3=datepart(dw,#dateCourante)
--si on est pas le 1er mai
if #dpart1 <> 5 AND #dpart2 <> 1
begin
--id parution
select #idPar = #idPar + 1
select #idParChaine = convert(varchar(10),#idPar)
--num parution
select #numPar = #numPar + 1
select #numParChaine = convert(varchar(20),#numPar)
--prix du jour courant
if datepart(dw,#dateCourante)=6
select #prixCourant = #prixVen
else
if datepart(dw,#dateCourante)=1
select #prixCourant = #prixDim
else
select #prixCourant = #prix
end
end
insert into #parTemp values (#idParChaine,#dateCourante,#numParChaine,#nbPagination,#prixCourant,#poids,#parCompt,#parOJD,#resVal)
end
select #dateCourante = dateadd(dd,1,#dateCourante)
END
END
Errors i get :
Error code 156, SQL state ZZZZZ: Incorrect syntax near the keyword 'WHILE'.
Error code 156, SQL state ZZZZZ: Incorrect syntax near the keyword 'end.
Error code 156, SQL state ZZZZZ: Incorrect syntax near the keyword 'End'.
i really don't understand, thank for help.
Pierre

Error 1064 you have error in Mysql bench syntax

Last two line show error .MY sqlwork bench show syntax error in last two line Limit 1
End
trying to run Database procedures.Error code Error 1064 you have error in Mysql bench syntax
CREATE PROCEDURE `xyz_Get`(
IN pPlaceId BIGINT,
IN pSwitchedCompanyId BIGINT,
IN pRequestedBy BIGINT
)
BEGIN
SELECT
`PlaceId`,
`CategoryCode`,
`CategoryName`,
`Description`,
`ParentCategoryId_FK`,
`ModuleId_FK`,
`LanguageId_FK`,
`CompanyId_FK`,
`OwnerCompanyId_FK`,
`IsDeleted`,
`IsArchived`,
`CreatedDate`,
`ModifiedDate`,
`CreatedBy_FK`,
`ModifiedBy_FK`
FROM `xyz_Place`
WHERE
`PlaceId` = pPlaceId AND
(
`CompanyId_FK` = pSwitchedCompanyId OR
`OwnerCompanyId_FK` = pSwitchedCompanyId
)
AND `IsDeleted` = 0
LIMIT 1;
END

SQL Error: ORA-00971: missing SET keyword

I am getting below error
Error at Command Line : 1 Column : 29
Error report -
SQL Error: ORA-00971: missing SET keyword
00971. 00000 - "missing SET keyword"
Please help me to solve this
here is the query that i used
update siebel.S_LOY_MEMBER a,siebel.s_contact b,siebel.s_contact_x c
SET
a.REC_PTNR_PROM_FLG ='N',
b.SUPPRESS_EMAIL_FLG ='Y',
b.SUPPRESS_FAX_FLG ='Y',
c.ATTRIB_09 ='Y'
where a.PR_CON_ID = b.par_row_id
and b.row_id = c.par_row_id
and a.PROGRAM_ID = '1-15P'
and a.REG_CHANNEL_CD ='Booking'
and a.MEM_NUM ='677609224'
Thanks
Praveen