I have tried a couple different approaches to doing this, and all seem to return an error. So in this exact situation, I'm trying to replace something in garrysmod with another. In this case, it's a playermodel. And I'm using the mysql pointshop. I want to replace specifically in the items row only the word "ironman" with "vector". Here are the different ones I have tried:
UPDATE `pointshop_data` SET `items` = REPLACE(`items`, 'ironman', 'vector')
and
UPDATE pointshop_data SET items = REPLACE(items, 'ironman', 'vector') WHERE items LIKE '%ironman%';
Both of which came from here: MySql - Way to update portion of a string?
Any different approaches I've tried I get the same syntax error: http://gyazo.com/03a6774b2d78956a8c5b41c588e9c568
I feel like I'm missing the smallest step here, but I did exactly as the answers stated in the other question.
try following query:
UPDATE 'pointshop_data' SET items = REPLACE(items, 'ironman', 'vector') WHERE items LIKE '%ironman%';
Related
This question already has answers here:
When to use single quotes, double quotes, and backticks in MySQL
(13 answers)
Closed 2 years ago.
I hope you all have a good day.
Actually I'm deploying a query to get a complete array of data. But the fact is that I need an Id, first of all, I guess, I must get the last Id first, then I can apply a mathematic operation to get its value + 1. The fact is that I've been trying different sentences and queries with no result.
This is my code:
function obtener_Id(){
global $mysqli;
$resultado_oId = $mysqli ->query("SELECT TOP 1 'id' FROM 'pacient' ORDER BY RowID DESC ")
$id_sacada = mysqli_fetch_assoc($resultado_oId);
$id_enLaMano = $id_sacada['id'];
return $id_enLaMano;
//$id_dinamica = $id_enLaMano + 1;
//return $id_dinamica;
}
As you can see guys, I've commented on the last two lines, cause I´m looking to get at least a value (The result from a query) But Idk if that is correct. Looking on the Internet I've seen relative posts which are solved just to apply the query that we can view under global declarations...
I've tried that on phpMyAdmin with no results and a bunch of errors...
You guys know the correct way to get the max value in the Id column? Or even if I'm doing badly correct me.
A lot of hugs and Luck!
Mizar ^^
I would suggest putting the serial number in a table. Read the serial no before insert, (lock the table, if required) insert the data, then increase the serial no by 1 and update the serial no table with increased value.
Please could someone help me understand why the following SQL doesn't work:
UPDATE `v2rns_content_new`
SET `images`= REPLACE(`images`, 'images\/news_images', 'images\/news_images\/legacy');
I am trying to find and replace the bold part of the following string (there are multiple records in the database with similar strings but the filenames e.g. example.png are different):
{"image_intro":"images\ /news_images\ /example.png","float_intro":"","image_intro_alt":"","image_intro_caption":"","image_fulltext":"","float_fulltext":"","image_fulltext_alt":"","image_fulltext_caption":""}
Please note: I asked a related question yesterday (which will provide some background) but I feel that this question is best asked separately - Updating all rows within a single column using phpMyAdmin
I have managed to solve the issue by changing the already escaped \ to \
e.g. UPDATE v2rns_content_new SET images = REPLACE(images, 'images\\/news_images, 'images\\/news_images\/legacy')
Thanks to #GeolezTrol for pointing me in the right direction.
I am trying to update a field in a MySQL table of around 4,000 records where the email
addresses matches about 90 email addresses.
I have looked through past answers and tried to get it right but seem to be getting more errors.
I am using phpMyAdmin and this is what I first started off with:
UPDATE `user_table`.`eb_users` SET `pause` = 'X' WHERE `eb_users`.`email` LIKE ('test1#test1.com', 'another#another.com', 'moreemail#email.com');
The above throws the "Operand should contain 1 column(s) error" - I then tried different
variants of the above and got similar errors.
It's probably basic but am just not getting it... any help appreciated
If you know all of the email addresses you need to match then you can look for matches against a collection using IN rather than LIKE
UPDATE `user_table`.`eb_users` SET `pause` = 'X' WHERE `eb_users`.`email` IN ('test1#test1.com', 'another#another.com', 'moreemail#email.com');
I'm trying to clean all duplicate results on a phonebook i have, that means i'm trying to compare landline1 to landline2 and if they are equal (but not empty) i would like to either NULL or just replace with empty string one of them.
i use the following line to list all the matching results:
SELECT * FROM `csv_confirmed` WHERE landline1=landline2 AND landline1!="";
which gives me a full list, but it's too many to edit manually and i'm trying to automate it.
What would be the easiest way to run UPDATE (or anything else that might work here) to clear the "landline2" column of the results i found ?
Just change your query to an update:
UPDATE csv_confirmed
SET landline2 = NULL
WHERE landline1=landline2 AND landline1!=""
I need to check phone number to see if they match but the issue is, that one table is in database A and another is in database B.
I am wondering is there away to do a search like this:
update `chk_dup`, new set chk_dup.dup='Y' WHERE chk_dup.phone = new.phone;
But I guess I would need to do something like this:
update `A.chk_dup`, B.new set A.chk_dup.dup='Y' WHERE A.chk_dup.phone = B.new.phone;
I any one knows how to search two tables in completely different databases that would help.
I think in your second one you had a syntax error, try this one:
UPDATE `A`.`chk_dup`, `B`.`new`
SET `A`.`chk_dup`.`dup`='Y'
WHERE `A`.`chk_dup`.`phone` = `B`.`new`.`phone`;