I have 2 posts in a table, with prices 500.00 and 88.98. When I run to sort at the highest price, Mysql returns me that 88.98 is greater than 500.00, the price field is a string, why does this happen?
I have 2 posts in a table, with prices 500.00 and 88.98. When I run to sort at the highest price, Mysql returns me that 88.98 is greater than 500.00, the price field is a string, why does this happen?
Because 5 comes before 8, as it is string it is comparing the characters. Change the data type to decimal.
You can follow what Douglas said, from the table structure to change the type of data for this field. As you can also convert from select to fetch the data using this syntax:
SELECT seu_campo FROM 'sua_tabela'
ORDER BY CONVERT(seu_campo ,DECIMAL(10,2)) ASC
;
I'm developing an application where you have to find a set value and literally walk 19 homes.
13000000 736363645C736363645F
6178747265653030311300000073
6363645F6178747265653030315F
Looking like this:
13000000 736363645C736363645F
617874726565303031 1300000073
6363645F6178747265653030315F
Looking like this:
13000000736363645C736363645F
617874726565303031 13000000 73
6363645F6178747265653030315F
Looking like this:
13000000736363645C736363645F
61787472656530303113000000 73
6363645F6178747265653030315F
Then, exchange one value for the other: 736363645C736363645F
61787472656530303 for 736363645F6178747265653030315F
Doing a loop by repeating the same function throughout the file.
======================== Edit
So:
13-00-00-00- 73-63-63-64-5C-73-63-63-64-5F-61-78-74-72-65-65-30-30- 31 -13-00-00-00- 73-63-63-64-5F-61-78-74-72-65-65-30-30-31-5F
Looking like this:
13-00-00-00- 73-63-63-64-5F-61-78-74-72-65-65-30-30-31-5F -13-00-00-00- 73-63-63-64-5C-73-63-63-64-5F-61-78-74-72-65-65-30-30-31
NOTE: I changed the value above after the "13-00-00-00" down
============================ @ I tried something similar to this:
%pre%A simple way is regular expression, using %code% :
%pre%In the case, I made you a regular expression with two groups: one internal (to take the 19 values individually) and one external, to get all 19 values at once.
Note that in Fiddle, %code% is exactly what you're looking for.
About invert to %code% the simple way is to implement this function ( best answer from here ):
%pre%Therefore:
%pre%Now I understand what you want. You want to locate the groups two by two, and then invert them.
This changes the regular expression, because you need to necessarily find two groups:
%pre%Find the largest group ( %code% ) and do another regular expression search on it. You will get two groups.
Just invert them and mount another %code% .
I tried to do something that seems to be what you want. You may have problems because the problem is not well defined. If I improve the setting, I can change it a bit and make a final, more organized version. I made a version with question originals and without the dashes as it was after the edit.
%pre%See working on dotNetFiddle .