UPDATE micro_finance_loans AS 'ML' SET ML.Loan_status=11
INNER JOIN micro_finance_customers AS 'MC' on MC.Customer_Id=ML.Customer_Id
WHERE ML.loan_status=10 AND MC.Number='4410188992243'
Can someone please tell me whats the error in this query, error as:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'inner join microfinance_customers as mc on mc.CustomerId=ml.CustomerId
where ml' at line 2
UPDATE micro_finance_loans AS ML
INNER JOIN micro_finance_customers AS MC on MC.Customer_Id=ML.Customer_Id
SET ML.Loan_status=11
WHERE ML.loan_status=10 AND MC.Number='4410188992243'
Try this instead
UPDATE micro_finance_loans AS 'ML' SET ML.Loan_status=11 from micro_finance_loans
INNER JOIN micro_finance_customers AS 'MC' on MC.Customer_Id=ML.Customer_Id
WHERE ML.loan_status=10 AND MC.Number='4410188992243'
Related
I have a update query
update B set B.i_description='travncore testing',B.Tm_id=35
from backlog B join backToSprint B1 on
B.b_id=B1.fk_back_id where B1.s_id=18
when run this query i got an error like
1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use
near 'from backlog B inner join backToSprint B1 on
B.b_id=B1.fk_back_id where B2.s_id=' at line 1
Any help would be greatly appreciated .
You can try below set should be afer join and before where clause
update backlog B
join backToSprint B1 on B.b_id=B1.fk_back_id
set B.i_description='travncore testing',B.Tm_id=35
where B1.s_id=18
The right grammer can be found at mysql-update-a-joined-table,so you can try with below
update backlog B
join backToSprint B1 on B.b_id=B1.fk_back_id
set B.i_description='travncore testing',B.Tm_id=35
where B1.s_id=18
I'm trying to get a MySQL query to work but keep getting an error. I want to join two tables tbl_collab and tbl.uploads with a WHERE clause but can't figure out what I've got wrong. Thanks.
SELECT tbl_collab.collab_userid, tbl_collab.file, tbl_collab.tbl_upload_id,
tbl_uploads.id,tbl_uploads.title,
FROM tbl_uploads
LEFT JOIN tbl_uploads.id ON tbl_collab.tbl_upload_id
WHERE tbl_collab.collab_userid='2'
I get this error:
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROM tbl_uploads LEFT JOIN tbl_uploads.id ON tbl_collab.tbl_upload_id WHERE ' at line 3
Your whole syntax after from and left join are wrong.
Please update it as per below query.
Try this:
SELECT tbl_collab.collab_userid,
tbl_collab.file,
tbl_collab.tbl_upload_id,
tbl_uploads.id,
tbl_uploads.title
FROM tbl_collab
LEFT JOIN tbl_uploads ON tbl_uploads.id = tbl_collab.tbl_upload_id
WHERE tbl_collab.collab_userid='2'
There is a comma (,) in your SELECT clause after tbl_uploads_title that should be removed.
SELECT tbl_collab.collab_userid, tbl_collab.file, tbl_collab.tbl_upload_id, tbl_uploads.id,tbl_uploads.title FROM tbl_uploads LEFT JOIN tbl_uploads.id ON tbl_collab.tbl_upload_id WHERE tbl_collab.collab_userid='2`
Just remove comma before FROM
Good Afternoon,
I am trying to update a table using price data from another table however I get an error using an inner join. I am sure its something very stupid but having spent the best part of my day on this its time to ask for help.
If I do the following SELECT statement to test my inner join syntax works as it should
SELECT *
FROM polaracc_osrs_property_field_value
INNER JOIN polaracc_osrs_properties
ON polaracc_osrs_property_field_value.pro_id = polaracc_osrs_properties.id
WHERE polaracc_osrs_property_field_value.field_id =112
However when I then try and run an update statement using the price from one table to populate the 2nd I get the below error
1064 - You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use
near 'FROM polaracc_osrs_property_field_value INNER JOIN
polaracc_osrs_properties ' at line 3
The syntax used for the update statement is below
UPDATE polaracc_osrs_property_field_value
SET polaracc_osrs_property_field_value.value_integer = polaracc_osrs_properties.price
FROM polaracc_osrs_property_field_value
INNER JOIN polaracc_osrs_properties
ON polaracc_osrs_property_field_value.pro_id = polaracc_osrs_properties.id
WHERE polaracc_osrs_property_field_value.field_id = 112
Your join needs to happen before you set your values like this:
UPDATE polaracc_osrs_property_field_value
INNER JOIN polaracc_osrs_properties
ON polaracc_osrs_property_field_value.pro_id = polaracc_osrs_properties.id
SET polaracc_osrs_property_field_value.value_integer = polaracc_osrs_properties.price
WHERE polaracc_osrs_property_field_value.field_id = 112;
Hope this helps.
My Query :
UPDATE i SET i.CurStock = i.CurStock-g.Qty
FROM inv_inventarymaster AS i INNER JOIN inv_goodsissue AS g
ON i.ItemName = g.ItemName WHERE g.DATE='2014-03-20';
Error:
You have an error in your SQL syntax; check the manual that correspond
to your MySQL server version for the right syntax to use near 'FROM
inv_inventarymaster as i INNER JOIN inv_goodsissue as g ON ' at line 1
Kindly help me getting the right syntax.
Try this ...Not Tested but as MYsql http://dev.mysql.com/doc/refman/5.0/en/update.html
UPDATE inv_inventarymaster AS i INNER JOIN inv_goodsissue AS g SET
i.CurStock = i.CurStock-g.Qty
WHERE i.ItemName = g.ItemName and g.DATE='2014-03-20';
its not a right thing to use FROM in Mysql UPDATE query.
You can use the query like this
UPDATE inv_inventarymaster AS i
INNER JOIN inv_goodsissue AS g ON i.ItemName = g.ItemName
SET i.CurStock = i.CurStock-g.Qty
WHERE g.DATE='2014-03-20';
I'm trying to delete multiple rows from multiple tables having the same condition but will always return syntax error.
This is the code:
DELETE FROM table1,table2,table3
WHERE guid = 'CE4EF453-937F-C7F9-7AE429VB0128'
The error code is:
1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use
near 'WHERE guid = 'CE4EF453-937F-C7F9-7AE429VB0128'' at line 2
You are missing INNER JOINs. Something like the following perhaps.
DELETE FROM table1,table2,table3
USING table1 INNER JOIN table2 INNER JOIN table3
WHERE table1.guid = 'CE4EF453-937F-C7F9-7AE429VB0128'
AND table2.guid = table1.guid
AND table3.guid = table1.guid
(Reference)
Give this one a shot:
DELETE FROM table1,table2,table3
WHERE table1.guid = 'CE4EF453-937F-C7F9-7AE429VB0128'
AND table1.guid = table2.guid
AND table1.guid = table3.guid