Canjucks Posted January 23, 2021 Share Posted January 23, 2021 I want to use an sql query where the column has text I want to sort my rows I display for each. I need some help in getting the syntax correct. I might be going about it the wrong way as in a better way is probably there I just don't know that way. $Offensive = $this->db->prepare("SELECT * FROM `some table` WHERE SC_desc = 'some text'"); Quote Link to comment Share on other sites More sharing options...
Curt Posted January 23, 2021 Share Posted January 23, 2021 You might need to be a little more clear but I think this is what you mean ? $Offensive = $this->db->prepare("SELECT * FROM `some table` WHERE SC_desc = 'some text' ORDER BY column_name DESC"); Or change DESC to ASC to switch the order they are sorted. Quote Link to comment Share on other sites More sharing options...
Magictallguy Posted January 23, 2021 Share Posted January 23, 2021 SELECT * FROM some_table WHERE text_column IS NOT NULL ORDER BY some_column 1 Quote Link to comment Share on other sites More sharing options...
Sim Posted January 23, 2021 Share Posted January 23, 2021 1 hour ago, Magictallguy said: SELECT * FROM some_table WHERE text_column IS NOT NULL ORDER BY some_column SELECT * FROM some_table WHERE text_column IS NOT NULL ORDER BY some_column Wimner!!- Unless he wants empty text results 🙂 Quote Link to comment Share on other sites More sharing options...
Canjucks Posted January 24, 2021 Author Share Posted January 24, 2021 thanks guys. I was trying to get a string to = a string and was put in the right direction on discord. It was quite a head scratcher for me particularly when you're trying to learn this .... now to get a function together and understand the #each so I get this in the categories the way I wish to have them Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.