Running the following query in MySql workbench as \ is an escape character.
UPDATE midshared.SETUP
SET DATAVALUE = 'C:\Documents and Settings\ADMINISTRATOR\Desktop\'
WHERE CODE = 'SAGEPATH'
manually changing to this does work.
UPDATE midshared.SETUP
SET DATAVALUE = 'C:\\Documents and Settings\\ADMINISTRATOR\\Desktop\\'
WHERE CODE = 'SAGEPATH'
However trying these methods that I've found on Stack Overflow don't work either -
UPDATE midshared.SETUP
SET DATAVALUE = REPLACE('C:\Settings\ADMINISTRATOR\Desktop\','\','\\')
WHERE CODE = 'SAGEPATH'
or
UPDATE midshared.SETUP
SET DATAVALUE = QUOTE('C:\Documents and Settings\ADMINISTRATOR\Desktop\')
WHERE CODE = 'SAGEPATH'
Can anyone point me in the right direction to fix it please?
Thanks
A
I tried the queries listed above
You can use double quotes safely and escape slashes as follows:
UPDATE midshared.SETUP
SET DATAVALUE = "'C:\\Documents and Settings\\ADMINISTRATOR\\Desktop\\'"
WHERE CODE_ = 'SAGEPATH'
Check the demo here.
Related
function SetLastCharacter(source, charid)
  MySQLAsyncExecute("UPDATE `user_lastcharacter` SET `charid` = '"..charid.."' WHERE `steamid` = '"..GetPlayerIdentifiers(source)[1].."'")
end
This is the code that is vulnerable I need to still be able to use the script however I need this to be fixed any help would be greatly appreciated.
Just double every single quote and backslash in the text:
function SetLastCharacter(source, charid)
charid = string.gsub(charid, "['\\]", "%0%0")
local text = GetPlayerIdentifiers(source)[1]
text = string.gsub(text, "['\\]", "%0%0")
MySQLAsyncExecute("UPDATE `user_lastcharacter` SET `charid` = '"..charid.."' WHERE `steamid` = '"..text.."'")
end
Why work only $txt4 and $textfinal not working?
$txt = $_GET['value'];
$txt2 = $_GET['value2'];
$txt3 = $_GET['value3'];
$txt4 = $_GET['value4'];
$txtfinal = $txt . $txt2 . $txt3;
$conn->query("UPDATE '".$txtfinal."' SET quantita = quantita + '".$txt4."'");
Remove the quotes around the table name
$conn->query("UPDATE ".$txtfinal." SET quantita = quantita + '".$txt4."'");
^-------------^---- here
But beware - your code is wide open to SQL injections! You should use Prepared Statements and stop patching your queries together. There is almost never a reason to make the table name variable.
Try
$txtfinal = "'".$txt."',"."'".$txt2."',"."'".$txt3."'";
The following tables exist:
Passerine_Survey_Observation
Species_Codes
I'm trying to set the common name in Passerine_Survey_Observation with that of Species_Codes:
UPDATE Passerine_Survey_Observation
INNER JOIN Species_Codes ON Passerine_Survey_Observation.SPEC_FK = Species_Codes.SPEC
SET Passerine_Survey_Observation.Species_Common_Name = Species_Codes.COMMONNAME;
It says an update will occur; however, nothing changes in Passerine_Survey_Observation.
Supposed update warning
If I do this an update does occur as expected:
SET Passerine_Survey_Observation.Species_Common_Name = 'test'
#Knox was onto something...
This behavior occurred because the target field (Passerine_Survey_Observation.Species_Common_Name) - in Design View - was a List Box (under the Properties > Lookup tab). Setting that to Display Control = Text Box resolved the problem. Oops.
Final code:
UPDATE Passerine_Survey_Observation
INNER JOIN Species_Codes ON Passerine_Survey_Observation.[SPEC_FK] = Species_Codes.[SPEC]
SET Passerine_Survey_Observation.Species_Common_Name = Species_Codes.[COMMONNAME]
WHERE Passerine_Survey_Observation.Species_Common_Name IS NULL;
I am new user with MySQL 5.6 and trying to UPDATE a table using NAVICAT
I trying to condition the SET statement with a WHERE. It seems I have taken the wrong approach. Can someone point me in the right direction?
UPDATE vacation_watch
INNER JOIN property_names
ON vacation_watch.Mstrfromproperty = property_names.MstrLink
INNER JOIN property_names_subnames
ON property_names_subnames.NameLink = property_names.NameLink
SET vacation_watch.Watch_Requester_Last = property_names.Name_Last,
vacation_watch.Watch_Requester_First = property_names.Name_First,
vacation_watch.Watch_Requester_Phone = property_names.Name_Phone,
vacation_watch.Emergency_Contact_Name = property_names_subnames.Sub_Name_Last WHERE property_names_subnames.Sub_Name_Type = "KEYHOLDER"
vacation_watch.Emergency_Contact_Phone = property_names_subnames.Sub_Name_Phone WHERE property_names_subnames.Sub_Name_Type = "EMERGENCY"
You are using two WHERE clauses and in the wrong way.
What you are looking for is actual conditional SQL. There is already an answer on SO that could help you achieving what you want to do here.
Furthermore, there can only be only one WHERE clause that applies on the global level, not at field level.
Something like:
UPDATE vacation_watch
INNER JOIN property_names
ON vacation_watch.Mstrfromproperty = property_names.MstrLink
INNER JOIN property_names_subnames
ON property_names_subnames.NameLink = property_names.NameLink
SET vacation_watch.Watch_Requester_Last = property_names.Name_Last,
vacation_watch.Watch_Requester_First = property_names.Name_First,
vacation_watch.Watch_Requester_Phone = property_names.Name_Phone,
vacation_watch.Emergency_Contact_Name =
CASE WHEN property_names_subnames.Sub_Name_Type = "KEYHOLDER"
THEN property_names_subnames.Sub_Name_Last
END
vacation_watch.Emergency_Contact_Phone =
CASE WHEN property_names_subnames.Sub_Name_Type = "EMERGENCY"
THEN property_names_subnames.Sub_Name_Phone
END
could work. I hope I got what you wanted to do correctly and my syntax is correct as I just wrote it in a text editor and didn't test it.
I have a 3D array in Matlab of uint16(basically it is just an image 1080x1920x3). I want to store it in mysql. Here is what I'm doing:
MySQL:
create table imgtest(img longblob);
Matlab:
% image_data - is my image as described before
raw_im = reshape(image_data,1,[]);
conn = database('test','root','root','Vendor','MySQL','Server','localhost')
x = conn.Handle;
insertcommand = ['INSERT INTO imtest (img) values (?)'];
StatementObject = x.prepareStatement(insertcommand);
StatementObject.setObject(1,raw_im)
StatementObject.execute
The problem is that I'm writing about 600k uint16 values into this blob field. But when I take this field from the DB, I always getting about 1.2 million of uint8 elements(exactly two times more).
So, is there a way to read this byte field as a set of uint16, but not uint8?
Thank you.
I have been doing something similar for one of my projects
basically there was one difference but maybe it would clarify something to you.
I was loading image directly to DB from file with command:
INSERT INTO BaseImage(Image)
SELECT * FROM OPENROWSET(BULK N'C:\co.jpg', SINGLE_BLOB) as image
and getting it back to Matlab required typecasting (just like #sebastian mentioned)
SQL_query = 'select TOP 1 pk_BaseImage,Image from BaseImage order by pk_BaseImage desc';
[data] = SQL_query_exec(SQL_query);
pk_BaseImage = data.Data.pk_BaseImage;
out = typecast(data.Data.Image{1,1},'uint8');
BUT..
it was not enough, I had to do some trick to use 'out' as image
I was forced to write it to temporary file and read it again to Matlab (I know it's strange but it worked very well and I could for example calculate DWT, DFT and so on)
image_matrix = get_image_matrix( out );
get_image_matrix function looks like:
function [ out ] = get_image_matrix( input )
targetfilename = 'temp.jpg';
%wynik
fid = fopen(targetfilename,'w');
if fid
fwrite(fid,input,'uint8');
end
fclose(fid);
out = imread(targetfilename);
delete(targetfilename);
end
I hope it will help you :)
One important notice - I used gray-scale images (uint8 type)
You can most probably typecast the uint8's into uint16's to get back at your original image data:
uint16_result = typecast(uint8_result, 'uint16');
I'm not familiar with the database toolbox - so there might well be a way to tell Matlab to do this on its own.
OK, thank you both. I've summarized your answers and this what I've got:
Since blob field is nothing more than byte array, then we should cast our data in matlab before writing it to the DB. After reading it from DB, we should cast them back.
Minimum working example is:
MySQL
create table imgtest(img longblob);
Matlab
% image_data - is my image as described before
raw_im = typecast(reshape(image_data,1,[]),'uint8'); %! the main string
conn = database('test','root','root','Vendor','MySQL','Server','localhost')
x = conn.Handle;
insertcommand = ['INSERT INTO imtest (img) values (?)'];
StatementObject = x.prepareStatement(insertcommand);
StatementObject.setObject(1,raw_im)
StatementObject.execute
After we can read it back:
res = exec(conn,'Select * from imtest')
array_uint8 = fetch(res);
array_uint8 = array_uint8{1};
array_uint16 = typecast(array_uint8,'uint16').
Hope this will help someone.