I've been used the solution, but it cannot solved for special character.
I've tried
SELECT address FROM myDatabase.users
where substring(address,1,1) = '"';
What should I do to remove or change any special character or specific character in database like that??
anyway, after I ask my friend, he show me that the error come from setting in mysql workbench, I should to unselect "Safe Updates" check box in Edit >> Preferences >> SQL Editor >> Query Editor. thanks for the answer.
you could use the REPLACE function, so something like:
UPDATE myDatabase.users
SET address = REPLACE( address, '"', '' )
WHERE address LIKE '"%';
Related
I'm executing MySQL scripts (Inserts) from TOAD, if my simple varchar field contains "?" or ":", the TOAD asks me to bind variables (#f0) when all I want is to insert that "?" and ":" LITERALLY from the sentence.
I need to SET sql_mode = 'PIPES_AS_CONCAT' and replace all instance of "?" and ":" to || CHAR(63) || to make it valid. If I escape with "\?" or "\:" it's no use, not like when escaping other special character which works.
INSERT INTO `specs` (`ID`, `ParentProductsID`, `SpecsGroup`, `SpecsSubGroup`, `SpecsSubGroup2`, `SpecsText`) VALUES (1289, 27, 'What\'s in the box?', '', '', 'User guide');
This statement asks to bind variable #f0, unless I make it like this which works fine but longer:
SET sql_mode = 'PIPES_AS_CONCAT';
INSERT INTO `specs` (`ID`, `ParentProductsID`, `SpecsGroup`, `SpecsSubGroup`, `SpecsSubGroup2`, `SpecsText`) VALUES (1289, 27, 'What\'s in the box' || CHAR(63) || '', '', '', 'User guide');
Is there an easier way?
Note: I'm using TOAD for MySQL, this might not be happening for other SQL Editor I suspect.
Update: This works fine when I tried in PHPMyAdmin, it treats the "?" literally in every inserts.
This is not (yet) an answer but more detailed questions:
I suspect what is happening is that somehow the strings are being escaped so the SQL doesn't realise the ?/: are literal.
Have you read the manual?
Does TOAD auto-escape the SQL commands given to it (thus double escaping)?
Can you work directly with the MySQL command line and see if the problem stil appears?
Can you try inserting data here? with a string which does not contain ay quote, escaped or otherwise to see if these factors are related?
Can you try using some other SQL interface if you can't use the command line, to see if the issue is specific to TOAD?
Can you check TOAD settings to ensure that it hasn't been set to automatically somehow expect every SQL to be a Prepared Statement. (yeah clutching at straws... but always check the settings!)
I've read how to perform a find-replace in mysql,
UPDATE `table_name`
SET `field_name` = replace(same_field_name, 'unwanted_text', 'wanted_text')
but i'm stuck with a particular string (my unwanted_text), that is
<span style="font-size: 12pt;">
In order to prevent any unwanted result, i'm testing my query just finding the previous string.
I've tried to escape double quotes with \" and even blank spaces with \ but it doesn't work.
<span\ style=\"font-size:\ 12pt;\">
How should be unwanted_text?
Solved. It was Phpmyadmin through its search function converting: it was adding another \.
Through direct sql input everything works fine.
I'm new to sql and for some reason, the arrow symbol ( -> ) that I am used to seeing in teh command line, which mean it is ready for input, is now displayed as ( '> ) and it does not accept commands. What does it mean and how do I get back to ( -> ) ?
Thanks
It means that it is treating any input which follows as part of a string literal, until it encounters a(n unescaped) string termination quote ' character.
This will have happened because you previously began the string literal with such a string termination quote character. For example:
mysql> SELECT foo
-> FROM tbl
-> WHERE bar LIKE 'somestring
'> this is still part of somestring'
-> ;
find the attached image
use '/ command and press enter then it will go on next line starting with ->
then use ; and press enter.
it happens if there is unbalanced '(single quote) in query.
It means you have an incomplete query. Most likely it's something related to a missing quotation, semi-colon at the end, or parentheses aren't closed.
You can exit the query with: '\c
Not sure what happens to the query but it gets you back to the mysql> prompt.
enter image description here
As you can see, I encountered the same issue, the solution is :
type '> in the command line, then insert some command as I did(please refer to the picture attached), and then the new line starts.
I'm new to sql and for some reason, the arrow symbol ( -> ) that I am used to seeing in teh command line, which mean it is ready for input, is now displayed as ( '> ) and it does not accept commands. What does it mean and how do I get back to ( -> ) ?
Thanks
It means that it is treating any input which follows as part of a string literal, until it encounters a(n unescaped) string termination quote ' character.
This will have happened because you previously began the string literal with such a string termination quote character. For example:
mysql> SELECT foo
-> FROM tbl
-> WHERE bar LIKE 'somestring
'> this is still part of somestring'
-> ;
find the attached image
use '/ command and press enter then it will go on next line starting with ->
then use ; and press enter.
it happens if there is unbalanced '(single quote) in query.
It means you have an incomplete query. Most likely it's something related to a missing quotation, semi-colon at the end, or parentheses aren't closed.
You can exit the query with: '\c
Not sure what happens to the query but it gets you back to the mysql> prompt.
enter image description here
As you can see, I encountered the same issue, the solution is :
type '> in the command line, then insert some command as I did(please refer to the picture attached), and then the new line starts.
I'm not exactly sure what happened because I migrated from One server to another of the same spec and SQL...
Still in comments and titles the new database shows the characters ' instead of '
and I was wondering if I could ask for help in either replacing ' with '
or if it was simpler just deleting '
Thanks so much...
Steff
You could use MySQL's REPLACE method (look here):
UPDATE
Changed the statement to reflect the OP's naming:
UPDATE database1.vb_ppgal_albums
SET pp_photos = REPLACE(pp_photos, ''', '\'')
Good luck.
The following is the coding that I use to update double-quote in MySQL. I use the REPLACE function. The first parameter is the field_name that I want to have searched, the second is the escaping of the double quote (\") as the search string, followed by escaping of the escape character (\) followed by the double quote, which will insert into the field name (\"). In the table I will now have a measurement of '1/2\"' instead of '1/2"', which was my goal. I hope this helps. (PS, the Where clause is for show, you may not need it.)
UPDATE `table_name`
SET
`field_name` = REPLACE(`field_name`, '\"', '\\"')
WHERE `Id` > 125