If i run this query i am getting an error:
What do i do wrong?
Query:
UPDATE cscart_profile_fields.value
SET cscart_profile_fields_data.value = '0'
FROM cscart_profile_fields_data
INNER JOIN cscart_user_profiles
ON cscart_profile_fields_data.object_id = cscart_user_profiles.profile_id
WHERE
where cscart_user_profiles.user_id = 5316 and
(
cscart_profile_fields_data.field_id = 65
or
cscart_profile_fields_data.field_id = 66)
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 cscart_profile_fields_data INNER JOIN cscart_user_profiles ' at line 3
Try this:::
UPDATE cscart_profile_fields_data
INNER JOIN cscart_user_profiles
ON cscart_profile_fields_data.object_id = cscart_user_profiles.profile_id
SET cscart_profile_fields_data.value = '0'
where cscart_user_profiles.user_id = 5316 and
(
cscart_profile_fields_data.field_id = 65
or
cscart_profile_fields_data.field_id = 66)
Related
I got error message :
Query error: 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 'AS ChildCnt from tbl_user_master u WHERE u.sponsor_id = '145' AND u.user_type = ' at line 4 - Invalid query: select u.user_id,(SELECT COUNT(o.user_id) FROM tbl_user_master o WHERE o.sponsor_id = u.user_id AND o.user_type = 2 AND o.status =1 AND NOT EXISTS (
mysql code :
$user_tree = $this->getAllRec("u.user_id,(SELECT COUNT(o.user_id) FROM tbl_user_master o WHERE o.sponsor_id = u.user_id AND o.user_type = 2 AND o.status = 1 AND NOT EXISTS (
SELECT p.user_id
FROM tbl_flamingo_product_order p
WHERE o.user_id = p.user_id AND p.status=3) AS ChildCnt",
"tbl_user_master u",
"WHERE u.sponsor_id = '".$user_id."' AND u.user_type = 2 AND u.status =1");
May you help me find out where is the syntax error?
it is ok. I found it.
just replace
status=3)
to
status=3))
UPDATE DFEntryValues
SET DFEntryValues.DFFieldvalue = NOW()
FROM DFEntryValues
JOIN DFEntries ON DFEntryValues.DFEntryID = DFEntries.DFEntryID
JOIN DynamicFormStructures ON DFEntries.DynamicFormStructureID = DynamicFormStructures.DynamicFormStructureID
JOIN Projects ON DynamicFormStructures.ProjectID = Projects.ProjectId
JOIN Clients ON Projects.ClientID = Clients.ClientID
JOIN DFFieldDefinition ON DFEntryValues.DFFieldDefinitionID = DFFieldDefinition.DFFieldDefinitionID
WHERE Clients.ClientID = '26' AND DFFieldDefinition.label = 'Geboortedatum';
I get the following error:
Error Code: 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 Clients.ClientID = '26' AND DFFieldDefinition.label = 'Geboortedatum' SET' at line 12
Can someone point me out what's wrong with this query?
Kind regards!!
It seems you are not using correct format.
Hope this helps.
UPDATE DFEntryValues JOIN DFEntries ON DFEntryValues.DFEntryID = DFEntries.DFEntryID
JOIN DynamicFormStructures ON DFEntries.DynamicFormStructureID = DynamicFormStructures.DynamicFormStructureID
JOIN Projects ON DynamicFormStructures.ProjectID = Projects.ProjectId
JOIN Clients ON Projects.ClientID = Clients.ClientID
JOIN DFFieldDefinition ON DFEntryValues.DFFieldDefinitionID = DFFieldDefinition.DFFieldDefinitionID
SET DFEntryValues.DFFieldvalue = NOW()
WHERE Clients.ClientID = '26' AND DFFieldDefinition.label = 'Geboortedatum';
I'm receiving an error on the below SQL in MySQL and i'm unsure why. I'm new to MySQL.
UPDATE I
SET I.user_comments = DD.value
FROM
redcap_user_information I
JOIN redcap_data D ON D.value = I.user_email AND D.project_id = 439 AND D.field_name = 'email'
JOIN redcap_data DD ON DD.record = D.record AND DD.project_id = 439 AND DD.field_name = 'irb'
WHERE
user_comments IS NULL
AND allow_create_db = 1
AND user_suspended_time IS NULL
ORDER BY I.user_email
The error is
Error Code: 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
redcap_user_information I
JOIN redcap_data D ON D.value = I.use'
Can anyone shed some light?
Not sure about the logic of the join part but the correct syntax for update with join would be as
update redcap_user_information I
JOIN redcap_data D ON D.value = I.user_email AND D.project_id = 439 AND D.field_name = 'email'
JOIN redcap_data DD ON DD.record = D.record AND DD.project_id = 439 AND DD.field_name = 'irb'
set I.user_comments = DD.value
WHERE
user_comments IS NULL --- use the table alias name to access the column
AND allow_create_db = 1 --- use the table alias name to access the column
AND user_suspended_time IS NULL --- use the table alias name to access the column
After executing this query:
DELETE from swimming_class as tb1 JOIN (SELECT class_id FROM `swimming_class`
left join swimming_school on swimming_school.school_id = swimming_class.school_id
where swimming_school.school_name is NULL) as temp ON temp.class_id = tb1.class_id
I'm getting 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 'as tb1 JOIN (SELECT class_id FROM swimming_class left join swimming_school on' at line 1
I think what you are really after is the following (SQL Fiddle):
DELETE sc
FROM swimming_class sc
INNER JOIN swimming_school ss ON ss.school_id = sc.school_id
WHERE ss.school_name is NULL
Why this sql shows mysql error?
DELETE FROM wp_comments
JOIN wp_commentmeta ON wp_comments.comment_id =wp_commentmeta.comment_id
AND wp_commentmeta.meta_key = 'somekey'
AND wp_comments.comment_post_ID = '1'
error string
[Err] 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 'INNER JOIN wp_commentmeta ON
wp_comments.comment_id =wp_commentmeta.comment_id A' at line 2
Please Advice me.
When using join in a delete statement you have to specify from which tables you want to delete
DELETE c
FROM wp_comments c
JOIN wp_commentmeta m ON c.comment_id = m.comment_id
AND m.meta_key = 'somekey'
AND c.comment_post_ID = '1'