Can anyone tell me what is wrong with this Query ?
UPDATE
violetta.navi__stop
SET
violetta.navi__stop.endHour = VB.endHour
FROM
violetta.navi__stop AS V
INNER JOIN
violetta_back.navi__stop AS VB
ON V.code = VB.code
This code sample works for me on my database:
SELECT
V.code, V.endHour
FROM
violetta.navi__stop AS V
UNIQUE
violetta_back.navi__stop AS VB
ON V.code = VB.code
Try this instead:
UPDATE
violetta.navi__stop v
INNER JOIN
violetta_back.navi__stop AS VB
ON V.code = VB.code
SET
v.endHour = VB.endHour
Related
Having a problem with the plugin DMSF in redmine I have found a link with a SQL query that could fix the issue, however I am using PostgreSQL and that query returns a syntax error directly on f.project_id.
The MySQL query is:
update dmsf_files f
set f.project_id = (select d.project_id from dmsf_folders d where d.id = f.dmsf_folder_id and d.system = 1)
where (select dmsf_folders.system from dmsf_folders where dmsf_folders.id = f.dmsf_folder_id) = 1;
What should be the PostgreSQL equivalent ?
I have found some online Database syntax translator but unfortunately with no success at all.
Remove the alias from the left side of the SET clause:
update dmsf_files f
set project_id = (select d.project_id from dmsf_folders d
where d.id = f.dmsf_folder_id and d.system = 1)
where (select dmsf_folders.system from dmsf_folders
where dmsf_folders.id = f.dmsf_folder_id) = 1;
I have the following SQL statement:
UPDATE tbl_Invoices
SET tbl_Invoices.Base = tbl_Bases.BasePrice
FROM tbl_Invoices
INNER JOIN tbl_Bases ON tbl_Bases.ProductNumber = tbl_Invoices.ProductNumber
AND tbl_Bases.ChangeOrderID = tbl_Invoices.ChangeOrderID
AND tbl_Bases.CustomerName = 'VALEO'
AND tbl_Bases.CountryCode = 'FR'
AND tbl_Bases.ContractYear = 0
Access keep telling me I have a syntax error (missing operator)
This drives me nuts. Can someone tell me what's wrong?
UPDATE ... FROM doesn't exist in Access SQL, here you do it like this:
UPDATE tbl_Invoices
INNER JOIN tbl_Bases ON tbl_Bases.ProductNumber = tbl_Invoices.ProductNumber
AND tbl_Bases.ChangeOrderID = tbl_Invoices.ChangeOrderID
AND tbl_Bases.CustomerName = 'VALEO'
AND tbl_Bases.CountryCode = 'FR'
AND tbl_Bases.ContractYear = 0
SET tbl_Invoices.Base = tbl_Bases.BasePrice
Thanks a lot.
I still have an error as the = 'VALEO' etc... are not allowed in Join but this is working if moved to a where clause:
UPDATE tbl_Invoices
INNER JOIN tbl_Bases ON tbl_Bases.ProductNumber = tbl_Invoices.ProductNumber
AND tbl_Bases.ChangeOrderID = tbl_Invoices.ChangeOrderID
SET tbl_Invoices.Base = tbl_Bases.BasePrice
WHERE tbl_Bases.CustomerName = 'VALEO'
AND tbl_Bases.CountryCode = 'FR'
AND tbl_Bases.ContractYear = 0
I need to update a table and this is my sql code so far but i'm getting the following error message:
Line 30: Incorrect syntax near ')'.
UPDATE dbo.Part
SET SupplierShortName = NationalSupplier.ShortName,
SupplierLongName = NationalSupplier.LongName
SELECT *
FROM dbo.Part
JOIN dbo.NationalSupplier
ON Part.SupplierNumber = NationalSupplier.Number
AND (ISNULL(Part.SupplierShortName,'') <> ISNULL(NationalSupplier.ShortName,'')
OR ISNULL(Part.SupplierLongName,'') <> ISNULL(NationalSupplier.LongName,''))
LEFT OUTER JOIN dbo.NationalPart
ON Part.NationalPartID = NationalPart.NationalPartID
WHERE Part.DWCreationEntityID = 1
AND NationalPart.NationalPartID is NULL
Thanks in advance for any valuable tips !
Try this:
UPDATE dbo.Part
SET SupplierShortName = NationalSupplier.ShortName,
SupplierLongName = NationalSupplier.LongName
FROM dbo.Part
JOIN dbo.NationalSupplier
ON Part.SupplierNumber = NationalSupplier.Number
AND (ISNULL(Part.SupplierShortName,'') <> ISNULL(NationalSupplier.ShortName,'')
OR ISNULL(Part.SupplierLongName,'') <> ISNULL(NationalSupplier.LongName,''))
LEFT OUTER JOIN dbo.NationalPart
ON Part.NationalPartID = NationalPart.NationalPartID
WHERE Part.DWCreationEntityID = 1
AND NationalPart.NationalPartID is NULL
You should alias the table names to make things concise.
Hello i'm trying to make an update with a select statement.
Here is my code
update recolha_hrs_2014 r set r.state = 'porval' from (select e.sigla
from dgrhe_entidade e) where r.state = 'finalizado' and r.qzp = '10'
and e.sigla = '145014'
However it gives me an error.
ERROR: subquery in FROM must have an alias
LINE 3: from (select e.sigla from dgrhe_entidade e)
Any suggestion. What am i doing wrong?
Hope you can help me
Thanks,
Try this:
update r
set set r.state = 'porval'
from recolha_hrs_2014 r
inner join dgrhe_entidade e on e.??? = r.????
where r.state = 'finalizado' and r.qzp = '10' and e.sigla = '145014'
I'm not sure which field(s) in dgrhe_entidade map to recolha_hrs_2014, but that's what needs to go in: "e.??? = r.????"
i have the following hql query:
UPDATE TaskAssessment taskAssessment
SET taskAssessment.activeFlag = false
WHERE taskAssessment IN
(
SELECT taskAssessment2
FROM TaskAssessment taskAssessment2
Where taskAssessment2.activeFlag = true
AND taskAssessment2.patient.id
AND taskAssessment2.needsLevel.careNeed = :careNeed
)
but its giving me errors:
You can't specify target table 'TASK_ASSESSMENT' for update in FROM clause
could anyone help me to correct the query for mysql and hibernate. thanks in advance.
To resolve You can't specify target table 'TASK_ASSESSMENT' for update in FROM clause, rewrite the query to use JOIN instead of IN (in mysql you need to write something like this):
UPDATE TaskAssessment a
INNER JOIN TaskAssessment a2 ON (a2.id = a.id)
SET a.activeFlag = 0
WHERE a2.active_flag = 1 AND
a2.patient_id = :patient_id AND a2.needsLevel_careNeed = :careNeed