why won't mySQL let me SET return=1? [duplicate] - mysql

This question already has an answer here:
Syntax error due to using a reserved word as a table or column name in MySQL
(1 answer)
Closed 7 years ago.
It makes no sense. I have a TINYINT field that is either 0 or 1 and I'm trying to set it like this:
UPDATE db_products SET return='1' WHERE product_id=342343434
But it tells me there's a mySQL syntax error. What am I doing wrong here? Is the problem that the field is called return? If so, how do I get around it without changing it?

In most cases, you can get around reserved word problems by enclosing with "ticks"; the quote-like thing that usually shares the ~ key.
UPDATE db_products SET `return`='1' WHERE product_id=342343434

Related

REGEXP in MYSQL isn't working for full word search all time [duplicate]

This question already has answers here:
What special characters must be escaped in regular expressions?
(13 answers)
What is a word boundary in regex?
(13 answers)
Closed 2 years ago.
I've a table like this,
values
-------------------
male,female
PHP 30
PHP (30)
PHP ($30),CSS ($20)
PHP {$30},CSS {$20}
PHP [$30],CSS [$20]
PHP (€30),CSS (20)
I've prepared the sql like this,
SELECT mytable.values FROM mytable WHERE mytable.values REGEXP '[[:<:]]PHP ($30)[[:>:]]'
It should match one row (4th), but it's not working.
It's also not working with
() / {} / [] or any types of symbols like $ / €
I want to mention here that,
MYSQL LIKE isn't the right thing for me I think, because it won't work if we want to match male.
REGEXP is working for PHP 30 here and it's working for only strings.
Could anyone please inform me what will be the best solution to match the exact word or sentence?
Thanks in advance.

MySQL throws an error when receiving my query [duplicate]

This question already has an answer here:
How to escape value keyword in mysql while using Select statement
(1 answer)
Closed 3 years ago.
I have to access a MySQL database that looks like this:
LOG_ID KEY TARGET CREATOR
1 okaytest 297d09d5-55fe faec09c0-159e
I can do the following query:
SELECT * FROM DATABASE WHERE LOG_ID=1
This would return me the column correctly.
But I can't do the following query.
SELECT * FROM DATABASE WHERE KEY='okaytest'
I believe that there might be a problem with the word KEY being a reserved keyword in MySQL, but I have to access that specific database, I can't change it's name and I must select it from the key
try like below by using the backtick `
SELECT * FROM DATABASE WHERE `KEY`='okaytest'
actually for reserve word you have to use this backtick otherwise it will thorow error here is the reserve word list
another options better not to use reserve word or incase of necessary you have use it by using backtick

unable to insert the image in MySQL [duplicate]

This question already has answers here:
How to use LOAD_FILE to load a file into a MySQL blob?
(6 answers)
Closed 6 years ago.
I'm trying to insert the image in MySQL whenever i tried to add the image it showed null value. Pls help me to add the image. I've give the correct path but still error has occurred
create table image3(id int, image longblob not null);
insert into image3(id,image)values(571185, load_file('D:\Images\3.jpg'));
The function load_file() returns the string representation of the file (it only works with text files).
What you're trying to do is insert binary data.
EDIT I was wrong, disregard the answer, instead look at this one: Load_File doesn't work
EDIT 2 Could it be that you have to use / instead of \? I know windows uses \ for path separators, but it's quite frankly the only OS to do so. Therefore I can imagine that MySQL (being multiplatform) uses "the correct separators".

SQL quoting error [duplicate]

This question already has answers here:
When to use single quotes, double quotes, and backticks in MySQL
(13 answers)
Closed 7 years ago.
I want to create a table using this Syntax
MySQL
But then as you can see, there's a red underline on "text".
I have tried using text.'tblemployee', 'text.tblemployee' , etc.
None of them worked.
Am I missing something here?
p.s : this is my first post ever, sorry if it is not really descriptive, Cheers.
Please replace the symbol apostrophe(') with the back quote(`)

mySql - find non-Ascii character in html [duplicate]

This question already has answers here:
How can I find non-ASCII characters in MySQL?
(10 answers)
Closed 9 years ago.
I'm trying to find all non-asci characters I have in my DB in a specific table and column. In that column are stored Html description, and in some of them I've exotic or non-existing characters (for example: Hà¶ganà¤s ).
I'm triyng to match them with this query:
SELECT * FROM project_version WHERE description REGEXP '[^()\x00-\xFF\,\.-\<\>="\' /:;&=]'
But I think I'm missing something, cause it returns all of my records. Does anyone any advice?
Thanks in advance
Try moving hyphen to start or end otherwise it needs to be escaped also ^ will be treated as literal ^ in character class:
SELECT * FROM project_version WHERE description REGEXP '[()\x00-\x7F,.<>="\' /:;&=-]'