Click here to Skip to main content
14,387,302 members
Rate this:
Please Sign up or sign in to vote.
See more:
This is my SQL Queries

SELECT top 1000 tr.page,tr.referrer,tr.keywords,tr.ms_id,tr.ms_date,tr.ip  FROM tblTracking tr 
WHERE tr.heirarchy LIKE '%*' + cast(@Cid as varchar) + '*%' and tr.site=@site and 
tr.ms_date between CONVERT(VARCHAR(11),@FromDt,101) and DATEADD(DAY,1,CONVERT(VARCHAR(11),@Todt,101)) 
order by tr.ms_date desc


I converted it into Mysql

SELECT COUNT(tr.id) as cnt FROM tblTracking tr 
WHERE tr.heirarchy LIKE '%*'; + concat(cast(p_Cid as varchar(1)) , '*%') and tr.site=p_site and 
tr.ms_date between DATE_FORMAT(p_FromDt,'%m/%d/%Y') and TIMESTAMPADD(DAY,1,DATE_FORMAT(p_Todt,'%m/%d/%Y')) 


Its giving me error
'+ ' not valid at this position excepting :END

When i removed ";" it give me following Error
'+ ' not valid at this position excepting: ';'

What I have tried:

I tried everything but couldn't get any thing
Posted
Updated 5-Nov-19 5:59am
Rate this:
Please Sign up or sign in to vote.

Solution 1

Semicolon terminates a statement in SQL (and in MySQL as well as SQL Server)
WHERE tr.heirarchy LIKE '%*'; + concat(cast(p_Cid as ...
                            ^
                            |
   
Comments
Akshay malvankar 5-Nov-19 3:41am
   
so what i have to do there ,i want to working this above query in Mysql
OriginalGriff 5-Nov-19 3:57am
   
Hint: start by removing the semicolon ...
Akshay malvankar 5-Nov-19 5:17am
   
i removed it still not working
OriginalGriff 5-Nov-19 5:35am
   
"It's not working" is one of the most useless problem descriptions we get: it tells us absolutely nothing about the problem. We don't know if you get an error message, or the wrong data, or even that that code compiles successfully!
Remember that we can't see your screen, access your HDD, or read your mind - we only get exactly what you type to work with.
So tell us what happens when you run that code, what you expected to happen, how you checked what happened. Help us to help you!
Akshay malvankar 6-Nov-19 2:07am
   
hey bro tried to read Richard Deeming answer without seeing screen
Rate this:
Please Sign up or sign in to vote.

Solution 2

You can do online rewrite of SQL from database A to database Any....

See here: SQLines - Online SQL Conversion - SQL Scripts, DDL, Queries, Views, Stored Procedures, Triggers, Embedded SQL[^]
   
Rate this:
Please Sign up or sign in to vote.

Solution 3

You're almost there - you just need to bring the other part of the string into the CONCAT call as well:
WHERE tr.heirarchy LIKE concat('%*', cast(p_Cid as varchar(1)), '*%')
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100