php - Numeric order when returning results from MySQL -
I have the following types of titles in my DB table:
Topic 1 Blank topic 2 Blah blah theme 3 blah blah ... topic 10 blah blah blah blah blah blah blah ad ...
The selected question will always return the result in this way:
... except topic 2, subject 3 etc ... until all the teenagers will get me Topic 2 etc ...
How can I get my results?
topic1 topic2 topic3
.. .. all the ways of topic 9 and only after that the subject can be 10?
This is your problem Database design topic number should be stored as integer if you are not design , Then try this query instead:
Select from the table 1 order from the CASE title (SUBSTRING_INDEX (title, '', 2), '', -1) Unnecessary);
Result:
'Topic 1Foo' topic 2 times '' subject 10 buzz ''
Test data :
drop table table table 1; Create Table Table 1 (title VARCHAR (100)) Faucet; Include table 1 (title) values ('theme 1fu'), ('subject 2 times'), ('subject 10 ringing');
Comments
Post a Comment