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
Related
I am using mysql 8.0.21. I am trying to execute this statement:
WITH t
AS (SELECT h.store_hsh,
Avg(s.sales) AS SALES_AVG,
Avg(s.customers) AS CSTMR_AVG
FROM sat_day_facts s
INNER JOIN link_day l
ON s.link_day_hsh = l.link_day_hsh
INNER JOIN hub_store h
ON h.store_hsh = l.store_hsh
GROUP BY h.store_hsh)
SELECT t.store_hsh,
Now() AS LOAD_DATETIME,
Now() AS LOAD_END_DATETIME,
t.sales_avg,
t.cstmr_avg,
(SELECT 1 + Count(*)
FROM t t1
WHERE t1.sales_avg > t.sales_avg) AS SALES_RANK;
but I keep having this error
ProgrammingError: 1064 (42000): 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 'WITH t as (select h.STORE_HSH, AVG(s.SALES) as SALES_AVG , AVG(s.CUSTOMERS) as' at line 1
I checked the manual of SQL but still don't understand what is going wrong.
Does anyone could help?
The query that is throwing an error for my MySQL DB is:
SELECT t1.GROUPNAME FROM user_group t0, group t1 WHERE ((t0.users_USERNAME =
?) AND (t1.GROUPNAME = t0.groups_GROUPNAME))
The error info is the following:
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 t1 WHERE
((t0.users_USERNAME = 'test') AND (t1.GROUPNAME = t0.groups_GROUP')
Okay so I know the problem is with the group t1 part. But I dont know what is wrong with it.
Click here to see that I have all the needed colums
Can any one find out what the problem could be here?
group is a reserved word in SQL. You should put quotes around it.
Some JPA providers do that automatically, whereas others don't ...
I am trying to create a mysql script that will search for results while at the same time filtering out duplicates of a particular field, I did some research and the code I found came in the format of something like this:
SELECT * FROM sites s INNER JOIN (SELECT h.*, row_number() over (PARTITION by muleid) as seqnum from history h ) h WHERE acceptid=2;
But it came up with the 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 '(PARTITION by muleid) as seqnum from history h ) h WHERE acceptid=2' at line 1
Is there anyone that can help?
I have this script calculates profit
Steps :
barangbeli = harsat / diameter
p1 = barangbeli * 10
p2 = prof / 100
result = barangbeli + profit;
thanks
CREATE VIEW tbkeluar as
SELECT mbarang.kdbrg, mbarang.nmbrg, mbarang.spek,if(SUM(bkeluar.qty), SUM(bkeluar.qty), 0)as qty,(tbmasuk.harsat/mbarang.diameter) as hargabeli, ((hargabeli*10)/100 )+hargabeli) as profit
LEFT JOIN bkeluar on mbarang.kdbrg = bkeluar.kdbrg group by mbarang.kdbrg
i have 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 profit from mbarang
LEFT JOIN bkeluar on mbarang.kdbrg = bkeluar.kdbrg gro' at line 2
The error message you received should be helpful enough to know whats wrong.
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 profit from mbarang LEFT JOIN bkeluar on mbarang.kdbrg = bkeluar.kdbrg gro' at line 2
Based from the error message, MySQL says that you have a syntax error because of this character ), with some characters appended for you to locate it: ) as profit from mbarang
As you can see from your SELECT statement, you have an extra )
SELECT mbarang.kdbrg
, mbarang.nmbrg
, mbarang.spek
,if(SUM(bkeluar.qty), SUM(bkeluar.qty), 0)as qty
,(tbmasuk.harsat/mbarang.diameter) as hargabeli
, ((hargabeli*10)/100 )+hargabeli) as profit
^ delete this extra parenthesis
Your SELECT statement (in CREATE VIEW) is missing its FROM clause. Do you mean FROM mbarang?
You're also probably missing at least one more JOIN; the table tbmasuk is mentioned in the SELECT clause, but isn't mentioned anywhere else in the statement.
I am attempting to execute the following query:
$query = "SELECT O. * AS NUM FROM (ab_order O)
LEFT JOIN ab_user U ON (O.id_user=U.id)
WHERE O.id IN ( SELECT OT.id_ab_order FROM ab_order_transaction OT
LEFT JOIN ab_transaction T ON (OT.id_ab_transaction = T.id)
LEFT JOIN ab_user U ON (T.id_user = U.id)
WHERE T.validated = 1 {$condTrans} ) {$condOrder}
ORDER BY {$orderCol} LIMIT $from, $numRecords ";
$queryDB = $DB->queryExec($query);
On the live server:
it works with MySql version 3.3.10.
PHP version 5.2.17.
But I need to use localhost:
XAMPP for linux, v. 1.7.7
PHP 5.3.8
MySql version 5.5.16.
On localhost it says:
MySQL 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 NUM
FROM (ab_order O)
LEFT JOIN ab_u' at line 1.
Is any easier way then uprgrade the live server Mysql database?
The aliasing of all the columns seems incorrect: SELECT O. * AS NUM. I'm unsure of why it would work on previous versions, but the as num should either be removed, or each column should be explicitly aliased.
You can define Alias for individual column in SELECT. Here is the issue
SELECT O. * AS NUM
Instead of this use
SELECT O. *
This is useful article Using Column Alias in SELECT Statement