MySQL: Get POSITION of Non-ASCII character - mysql

I have an example string like,
"Kim_!#$Maria"
The '_' could be anything that is not a letter or a number. So I want to find the position of the first non-Numeric/Alphabet character.
We are using MariaDB 5.5. The option to upgrade to version 10+ is beyond the scope of this question, as we are bound by the client's specifications.
Tried this but I get syntax errors.
LOCATE(REGEXP "[\\x00-\\xFF]|^$", myField))
Category Timestamp Duration Message Line Position Error 24/07/2019
4:08:38 PM 0:00:04.612 MySQL Database Error: You have an error in your
SQL syntax; check the manual that corresponds to your MariaDB server
version for the right syntax to use near 'REGEXP "[\x00-\xFF]|^$",
ced.Deckhand)) as FirstWord FROM Crew_Emergency_Dril' at line 1 15 81
I am an SQL Server guy - not familiar with MySQL syntax.

Related

web application got a error mysql query

select b1.blog_id, blog_name, blog_desc, b1.blog_date, blog_author, blog_img, ifnull(count(blog_cmt),0) AS blog_cmt
from blog b1, user_blog b2"
I got a error in this:
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 '"' at line 1
Error #1064 means that MySQL can't understand your command. To fix it:
Read the error message. It tells you exactly where in your command
MySQL got confused.
Check the manual. By comparing against what MySQL
expected at that point, the problem is often obvious.
Check for reserved words. If the error occurred on an object identifier, check
that it isn't a reserved word (and, if it is, ensure that it's
properly quoted).
You need to remove the quotes at the end and run your query. Looks like there is a typo, you intended a ; instead.
select b1.blog_id, blog_name, blog_desc, b1.blog_date, blog_author, blog_img, ifnull(count(blog_cmt),0) AS blog_cmt
from blog b1, user_blog b2;

Learning IN values

I'm trying to do a IN values statement. This is my query:
I did mysql_escape_string on each of the elements in the IN so mysql_escape_string('http://www.blah.com/%s') gave me http://www.blah.com/%s
SELECT * FROM social_handlers WHERE (`group` = 0 OR `url_template` IN ("http://www.blah.com/%s", "totally bogus val")) AND update_time > 0
It keeps telling me this error though:
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 'url_template IN ("http://www.blah.com/%s", "totally bogus val")) AND update_ti' at line 1
How can I identify this error?
This is my social_handlers table:
I also had to do mysql_set_charset('utf8',$connectid); because i support Russian and Chinese characters.

Extract data between two phrases in MySQL?

I am trying to extract data between two sets of characters in MySQL. To keep the example somewhat simple, I am looking for the text between and in a column called STAGE_DATA.
Here is the SQL I have now:
SELECT
SUBSTR(STAGE_DATA,
LOCATE('<title>',STAGE_DATA)+1,
(CHAR_LENGTH(STAGE_DATA) - LOCATE('<title>',REVERSE(STAGE_DATA))
- LOCATE('</title>,STAGE_DATA)))
FROM Stage_Table
But it is giving an 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 ''</title>,STAGE_DATA))) FROM Stage_Table' at line 5
Why?
Thank you!

problems with accent in mysql client SQuirreL

I use SQuirreL SQL client Version 3.5.3
I wanted to do an insert of a text with accent like éèà but I get a syntax error. The follow select statement doesn't work:
select 'élève';
The error is the following:
Error: Syntax error or access violation, message from server: "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 ''élèv' at line 1"
when I delete the é and è it works.
Does someone know how I can solve that accent problem ?
I just tried in my version of squirrel:
select 'élève' from dual;
Its on oracle. It worked without error. You probably need to make sure your connection is set up to handle unicode and that the underlying database supports that character set. Is that syntax even valid for your database? (I had to add "from dual" in order for it to become valid SQL).

(ASP) MS Access -> MySQL: Error in Select, where [..] strings

I am using a portal system on my website and modified the ASP code heavily.
Since the website is growing, I want to migrate from MS Acces to MySQL.
Now, I think the portal I'm using (and some code I inputted) aren't MySQL compatable, because when I switch to the MySQL database, I get the following error.
Microsoft OLE DB Provider for ODBC Drivers error '80040e14'
[MySQL][ODBC 5.1 Driver][mysqld-5.1.55-community]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 '[EzModuleID],
[ModName] From EzCore_Plugin Where IsModActive='1'' at line 1
[website]\WWWROOT\BOXX\INCLUDES../../includes/include.asp, line 3736
The SQL string regarding this line is the following:
Select [EzModuleID], [ModName] From EzCore_Plugin Where [IsModActive] = 1;
Im new to MySQL and I can't find why this is giving an error.
I've tried the quote's around 1, removing [], removing the space..
I think that when I figure out why this is causing an error, I can continue modifying the rest to make the website work on mysql.
Lose the square brackets
(I might as well post this as the answer rather than a comment)
In MySQL column and table names can be escaped with the backtick character ` or if the ANSI SQL mode is enabled with double quotes ".
Your WHERE clause (according to the error message) is Where IsModActive='1'. This works if IsModActive is a text column. If it is numeric, drop the single quotes. If IsModActive is a Boolean, change the clause to Where IsModActive IS true.
See: is operator