|
This could be intended . With this a pointer to the first block in the data file that has a record with that value for its clustering field This seems reasonable
|
|
|
|
|
Hi,
I have a table with floor_id field.
The floor_id is null and I am trying to read it
when I read it using where floor_id = NULL I don't get the correct result but when I try where floor_id IS NULL it's working
so how can I do when passing a parameter like where floor_id = param_floor?
Thanks,
Jassim
Technology News @ www.JassimRahma.com
|
|
|
|
|
You can do it like this in MSSQL
WHERE ISNULL(Floor_id,'') = ISNULL(param_floor,'')
=========================================================
I'm an optoholic - my glass is always half full of vodka.
=========================================================
|
|
|
|
|
As a general solution you can try:
WHERE floor_id = param_floor
OR (floor_id IS NULL AND param_floor IS NULL)
modified 3-Dec-14 15:06pm.
|
|
|
|
|
hmm but can I ask why?
I was using just floor_id = param_floor in other application and it was working fine.. why it's acting funny now?
Technology News @ www.JassimRahma.com
|
|
|
|
|
You cannot equal null in tristate logics, it's undefined and does not equal anything.
You can only check for null in both the field and the parameter.
|
|
|
|
|
so what if I want to say:
floor_id = param_floor
where the passed param_floor from my application could be a value or null.
How can I do this?
Technology News @ www.JassimRahma.com
|
|
|
|
|
Based on your question and Jassim Rahma wrote: where the passed param_floor from my application could be a value or null.
floor_id = param_floor
is valid.
“That which can be asserted without evidence, can be dismissed without evidence.”
― Christopher Hitchens
|
|
|
|
|
GuyThiebaut wrote: is valid.
but it returns nothing when the passed value is null and I do have null in the table!
here is my stored procedure:
SELECT assets$audit.audit_id,
assets$audit.audit_date,
assets$status.status_name,
assets$conditions.condition_name,
assets$audit.quantity
FROM assets$audit
JOIN assets$status ON `assets$status`.status_id = assets$audit.audit_status
LEFT JOIN assets$conditions ON `assets$conditions`.condition_id = assets$audit.audit_condition
WHERE item_id = param_item_id
AND location = param_loaction
AND floor = param_floor
AND room = param_room
AND department = param_department
AND employee = param_employee
ORDER BY audit_date DESC, created_date DESC;
Technology News @ www.JassimRahma.com
|
|
|
|
|
Read and understand this visual explanation of sql joins[^] then you will have an idea of what is happening.
You may not have a null value in the table but you certainly have a left join which will return nulls if there is no corresponding row on the right side of the join.
“That which can be asserted without evidence, can be dismissed without evidence.”
― Christopher Hitchens
|
|
|
|
|
the left join dose not return null
Technology News @ www.JassimRahma.com
|
|
|
|
|
and this is my .NET application code:
sql_connection = new MySqlConnection(xmlClass.get_connectionstring("Assets\\Assets"));
sql_connection.Open();
sql_command = new MySqlCommand("sp_populate_asset_audits", sql_connection);
sql_command.CommandType = CommandType.StoredProcedure;
sql_command.CommandTimeout = Convert.ToInt32(string_encryptor.DecryptString(xmlClass.read_xml_value("Assets\\Assets", "CommandTimeOut"), "JassimRahma@731004167"));
sql_command.Parameters.AddWithValue("param_item_id", item_id).MySqlDbType = MySqlDbType.Int32;
sql_command.Parameters.AddWithValue("param_loaction", Convert.ToInt32(gridLocation.GetRowCellValue(gridLocation.FocusedRowHandle, "location_id"))).MySqlDbType = MySqlDbType.Int32;
if (gridLocation.GetRowCellValue(gridLocation.FocusedRowHandle, "floor_id") != null) sql_command.Parameters.AddWithValue("param_floor", Convert.ToInt32(gridLocation.GetRowCellValue(gridLocation.FocusedRowHandle, "floor_id"))).MySqlDbType = MySqlDbType.Int32; else sql_command.Parameters.AddWithValue("param_floor", DBNull.Value).MySqlDbType = MySqlDbType.Int32;
if (gridLocation.GetRowCellValue(gridLocation.FocusedRowHandle, "room_id") != DBNull.Value) sql_command.Parameters.AddWithValue("param_room", Convert.ToInt32(gridLocation.GetRowCellValue(gridLocation.FocusedRowHandle, "room_id"))).MySqlDbType = MySqlDbType.Int32; else sql_command.Parameters.AddWithValue("param_room", DBNull.Value).MySqlDbType = MySqlDbType.Int32;
if (gridLocation.GetRowCellValue(gridLocation.FocusedRowHandle, "department_id") != DBNull.Value) sql_command.Parameters.AddWithValue("param_department", Convert.ToInt32(gridLocation.GetRowCellValue(gridLocation.FocusedRowHandle, "department_id"))).MySqlDbType = MySqlDbType.Int32; else sql_command.Parameters.AddWithValue("param_department", DBNull.Value).MySqlDbType = MySqlDbType.Int32;
sql_command.Parameters.AddWithValue("param_employee", DBNull.Value).MySqlDbType = MySqlDbType.Int32;
Technology News @ www.JassimRahma.com
|
|
|
|
|
It was a general solution i gave you, so it work for that case too.
|
|
|
|
|
Have a bit of a google as there is no simple way to explain it, however it goes something like this:
Null is not nothing, null is indeterminate, in other words null is an unknown value.
So in trying to compare an unknown value with another unknown value the result is always false.
Null == Null returns false.
“That which can be asserted without evidence, can be dismissed without evidence.”
― Christopher Hitchens
|
|
|
|
|
Hello Jassim,
while working in a procedure then i got the same problem. so based on my experience i would suggest to use decode function. decode function is similar to if else block.
decode(floor_id,null,1,floor_id)=decode(param_floor,null,1,param_floor)
thanks in advance
regards,
Sundeep
|
|
|
|
|
I have decimal(10,2) table column, is there way to format it like if you have 10.02 it will display 10.02 then if you 10.50 it will display 10.5.
It look like that format of .ToString("##.##") in c#.
BTW this is on MySQL.
I just want to omit the last zero of the decimal.
I will appreciate for any help will come.
modified 20-Nov-14 19:30pm.
|
|
|
|
|
Where will the number display, in a report, in a browser, in a Windows Form?
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Actually it will be used in windows forms.
|
|
|
|
|
If you convert it to float and then round in SQL it would work as you need.
check this
declare @no float=10.20
select Round(@no,2)
i have executed it in sql server, so check if that works in My SQL or not
Mark the answer as accepted if that worked for you .
And for down-voters please specify the reason to improve the solution .
|
|
|
|
|
Thank you for your response but, it doesn't seems will work on MySql
|
|
|
|
|
did you tried it
Mark the answer as accepted if that worked for you .
And for down-voters please specify the reason to improve the solution .
|
|
|
|
|
Yes I did, but there is no way I can cast decimal to float.
I did a work around but it is ugly, it could cause a performance issue, so I am still looking for a better solution.
|
|
|
|
|
In one table i am having 30 columns,in each column i mentioned data type as long text with character set as utf-8.When i am inserting the text from c# it only saving some limited number of characters,It is not saving full text.I want to insert long type text to almost to 30 columns I tried with changing different data types and character sets but not working.Please help me in getting this mysql problem.Example text from c# to insert in mysql column
height:30px;width:70px;background-color:rgba(255,255,255,1);color:#000000;font-family:Francois One, sans-serif;font-size:14px;padding:0px;margin:0px;border-radius:0px;border:solid 0px rgba(255,255,255,1);
|
|
|
|
|
Soooo... what's the definition of the column?
Where's the code you're using?
|
|
|
|
|
I am trying to replace names found in 'xml' fieldname as hyperlinks, by matching with the names in database_tags.
I am using the following function below, however the UDF is only recognizing one name from the XML fieldname data, instead of all the names present in the XML data.
ALTER FUNCTION [dbo].[ReplaceTags](@XML VARCHAR(MAX))
RETURNS VARCHAR(MAX)
AS
BEGIN
DECLARE @N VARCHAR(MAX)
SELECT @N = [Name] FROM [dbo].[database_tags]
WHERE @XML LIKE '%'+[Name]+'%'
AND UploadDate >= '2014-09-01'
IF @N IS NOT NULL
BEGIN
SELECT @XML = REPLACE(@XML,
@N,
'<a href="<a href="pagename.aspx?tag='+@N+'">'+@N+'</a>')
END
RETURN @XML
END
for example, if the XML input data is the following: It consists of: BANKP, BCJA, BCJAM, BFTH, BFTH, and EMPOP.
But the updated function is only recognizing two of names BFTH, BFTH , as hyperlinks, from the database_tags table.
Is there a way to get the function to recognize more than one names as hyperlinks.
Thank you very much for your time and help.
|
|
|
|