You have an error in your SQL syntax; check the manual that corresponds to your MySQL
- by LuisEValencia
I am trying to run a mysql query to find all occurences of a text. I have a syntax error but dont know where or how to fix it
I am using sqlyog to execute this script
DECLARE @url VARCHAR(255)
SET @url = '1720'
SELECT 'select * from ' + RTRIM(tbl.name) + ' where ' +
RTRIM(col.name) + ' like %' + RTRIM(@url) + '%'
FROM sysobjects tbl
INNER JOIN syscolumns col ON tbl.id = col.id
AND col.xtype IN (167, 175, 231, 239) -- (n)char and (n)varchar, there may be others to include
AND col.length > 30 -- arbitrary min length into which you might store a URL
WHERE tbl.type = 'U' -- user defined table
1 queries executed, 0 success, 1 errors, 0 warnings
Query: declare @url varchar(255) set @url = '1720' select 'select * from ' + rtrim(tbl.name) + ' where ' + rtrim(col.name) + ' like %' ...
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 'declare @url varchar(255)