Good morning!
I've googled the question, but could not find the information. There is a <table> with random number of <td>s (each <tr> contains 3 <td>s). How to reverse the order of each <td> in this table? The initial order is:
<table><tr><td1></td><td2></td><td3></td></tr>
<tr><td4></td><td5></td><td6></td></tr></table>
I need:
<table><tr><td6></td><td5></td><td4></td></tr>
<tr><td3></td><td2></td><td1></td></tr></table>
Would appreciate any assistance or idea!
Same result. And it doesn't matter what I include in REPLACE: REPLACE (price, ' ','') or REPLACE (price, ' ','') or REPLACE (price, '194','') or even REPLACE (price, HEX(C2),'')
This was with CAST, without CAST those queries return just the same that is in the price column
No, I've tried this one, but the result is the same. Table name is different, I've changed it. Do you try the query on MySQL?
First, I thought that something was wrong in PHP code, but now I'm checking directly in PHPMyAdmin. And there is no error notes in it. As we can see, REPLACE operator doesn't work correctly, it doesn't remove spaces. It just returns values.
I don't know why there are TEXT (not INT or DECIMAL). I was just given this task without permission to change the table fields
There is a table with prices (TEXT), I need to sort it as INT. And there is a space in the middle of it. So I use REPLACE for removing spaces and CAST for switching to signed INT. This query:
SELECT price, CAST(REPLACE(price,' ','') AS signed FROM table ORDER BY CAST(REPLACE(price,' ','') AS signed)
Returns this:
price CAST (price AS signed)
8 791 8
8 791 8
8 082 8
9 374 9
9 823 9
10 186 10
12 698 12
12 257 12
13 959 13
14 920 14
14 463 14
15 132 15
16 117 16
16 023 16
16 606 16
It sorts digits before a space, but do not return the whole price. I need to sort it correctly.
Please help me with this query or at least give me a hint!
We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.