I am getting below error when I have below SQL for mySQL. Can someone please help me what am I doing wrong. OR Is there any better way to achieive same ?
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 '(SELECT role FROM temp_scrconflict WHERE release = 'GROUP6')
= ANY (SELECT ' at line 2
Select * from `temp_scrconflict`
WHERE ANY (SELECT role
FROM `temp_scrconflict`
WHERE `release` = 'GROUP6') = ANY (SELECT role
FROM `temp_scrconflict`
WHERE `release`
IN ('ER_JUNE15', 'ER_APR15'))
I've never used it myself, but according to the official documentation:
"The ANY keyword [...] must follow a comparison operator"
Error is in below pointed line. See Documentation
Select * from `temp_scrconflict`
WHERE ANY (SELECT role <-- Here
You need to use a column name along with a comparison operator like
where some_column > ANY (subquery)
You can modify your query to be like below using IN operator
Select * from `temp_scrconflict`
WHERE (SELECT distinct role
FROM `temp_scrconflict` WHERE `release` = 'GROUP6') IN (SELECT role
FROM `temp_scrconflict` WHERE `release` IN ('ER_JUNE15', 'ER_APR15'));
Related
the title isn't very specific but I don't know how to make it better. I've got this error in my sql telling me something is wrong but I don't understand why it's wrong, currently using mysql 8.0.24. If you wonder why it looks strange it's because I use it in lua
Sql:
local q = [[SELECT id, hex_id, steam_id, community_id, name, ip, rank FROM users WHERE hex_id = #id;]]
local v = {["id"] = hexId}
Error:
An error happens for query "SELECT id, hex_id, steam_id, community_id, name, ip, rank FROM users WHERE hex_id = ?; : ["steam:*****"]": ER_PARSE_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 'FROM users WHERE hex_id = 'steam:*****'' at line 1
RANK is a keyword in MySQL 8. You need to enclose it inside backticks:
SELECT id, hex_id, steam_id, community_id, name, ip, `rank` FROM users ...
I am getting error in the partition clause. Please help me. The error is
Select Model_Name,
Case Model_Subtype
When 'Weight' then 'Static'
When 'Linked Account' then 'Dynamic'
When 'Flexible' then 'Dynamic'
Else 'Not Defined'
End as Model_Type, Security_Name, Market_Value,Weight,
Case When Weight = 0 And Market_Value= 0 Then 0
When Weight = 0 Then Cast(Market_Value/ nullif(SUM(market_Value)
OVER (Partition by Model_Name),0) AS Decimal (10,4))
When Weight !=0 Then Weight/100
Else Weight End as Target_Weight,
vehicle.Vehicle_Name
from
OFF_PRODUCT_MODEL model
Join OFF_PRODUCT_MODEL_TARGET target on target.Model_Id = model.Model_Id
Join OFF_PRODUCT_SECURITIES Sec on sec.Security_Id = target.Security_Id
left outer Join Offer_Back_End.tblStrategies Strategy on Strategy.Vestmark_Sleeve_Code = model.Model_Name
left outer join Offer_Back_End.tblVehicles vehicle On vehicle.Vehicle_Id = strategy.Vehicle_ID
Where (Strategy.Active_Strategy is null or Strategy.Active_Strategy = 1)
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 '(Partition by Model_Name),0) AS Decimal (10,4))
When Weight !=0 Then Weight/' at line 11
Umm, OVER (Partition by Model_Name) is analytical function which MySQL unfortunately doesn't support and don't have them and so you are getting the said error.
MySQL does not support OVER() clause. In general Window Functions are not part of MySQL.
You can however emulate it - please refer to the following answer:
https://stackoverflow.com/a/20432371/900564
Can anyone help with this? I've just switched web servers and I'm testing everything is working but I'm seeing this error. Any ideas whats wrong with the query? It seemed to be valid on my last host
Critical Error
A database error has occoured.
Error Returned mySQL query error: SELECT f.* AS fixtures,
team1.teamName AS HomeTeam,
team1.tid AS HomeTeamID,
team2.teamName AS AwayTeam,
team2.tid AS AwayTeamID,
GROUP_CONCAT(n.extra separator ',') AS scorers,
GROUP_CONCAT(n.homeEvent separator ',') AS homeEvent,
GROUP_CONCAT(n.eventType separator ',') AS eventType
FROM fixtures f
LEFT JOIN notifications n ON n.fixtureID = f.fid
LEFT JOIN teams team1 ON team1.tid = f.HomeTeam
LEFT JOIN teams team2 ON team2.tid = f.AwayTeam
WHERE f.kickoff > 1403823600 AND f.lid=1
GROUP BY f.fid
ORDER BY n.time ASC, f.kickoff ASC
mySQL 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 fixtures,
team1.teamName AS HomeTeam,
team1.tid AS HomeTeamID,
' at line 1
You can't cast a wildcard like that.. Casting is only for single fields
SELECT f.* AS fixtures
Try something like
SELECT f.fixtures AS fixtures, f.field AS field
etc
I don't know what kind of sql engine did you run on your previous webserver, but this is actually not allowed:
SELECT f.* AS fixtures
You need to specify a column, you can't use the wildcard for casting.
i have error on sql statment
SELECT temp.* FROM
(SELECT th1.process_id,th2.process_id FROM `thread` as th1,`thread` as th2
where (th1.thread_id=th2.thread_id)and
(th1.process_id!=th2.process_id) and
(th1.analysis_id='".$analysis_id."' ) and
(th2.analysis_id='".$analysis_id."' )) as temp
where ((t emp.p1 NOT IN (select pr.parent_process_id from process as pr
wherer pr.process_id=th2.process_id and (th2.analysis_id='".$analysis_id."' )
and (pr.analysis_id='".$analysis_id."' )))
or (temp.p2 NOT IN
(select pr1.parent_process_id from process as pr1
wherer pr1.process_id=th1.process_id and (th2.analysis_id='".$analysis_id."' )
and (pr1.analysis_id='".$analysis_id."' ))))
You have an obvious syntax error using wherer instead of where.
wherer pr.process_id=th2.process_id and
Should be
where pr.process_id=th2.process_id and
When MySQL reports an error similar to Check the manual for the correct syntax to use near..., look exactly to that location or to the character immediately before it for your syntax error.
check the manual that corresponds to your MySQL server version for the right syntax to use near 'wherer pr.process_id=tem.p2
I have two MySQL tables:
Group(gr_id, gr_name, gr_description, parent_id)
Group_has_User(User_id, Group_id)
I'm trying to execute the query:
SELECT group.gr_id, group.gr_name, group.gr_description, group.parent_id
FROM group, Group_has_User AS gu
WHERE (group.gr_id = gu.Group_id) AND gu.User_id = 1
It gives an 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 'group, Group_has_User AS gu WHERE (group.gr_id = gu.Group_id) AND gu.User_id = 1' at line 1
How should I write it correct?
group is a keyword in SQL. Enclose such names in backticks
FROM `group`, Group_has_User AS gu
group is a keyword in SQL. Try giving your tables more sensible names, or using:
SELECT g.gr_id, g.gr_name, g.gr_description, g.parent_id
FROM `group` g, Group_has_User AS gu
WHERE (g.gr_id = gu.Group_id) AND gu.User_id = 1
Try this. Remove the "AS" keyword after the table name Group_has_User and execute the query
Maybe you must write 'Group', not 'group'.