Skip to content
Advertisement

I can’t get the correct output when I use / ORDER BY from my SQL example?

I was playing around SQL sample that I wrote and I’m quite surprised that I couldn’t get the correct output when I use less than, greater than or ORDER BY.

for example, select player_name, jersey_number from Players order by 'jersey_number' desc; it should give players name and jersey number sort descending order from their jersey number. However, this is what I’m getting from the above query:

Similarly, when I request to show me only 'player_age' < 30 from this query: select player_name, player_age from Players where 'player_age' < 30;the output is incorrect based on this screenshot:

This is also from phpMyAdmin page:

enter image description here

I’m using MariaBD via Mac terminal and I imported my .sql file through phpMyAdmin website.

Here’s Players table and value inersion:

NOTE: I have deleted a couple tables include: Teams, Owners, Matches, Team_ownerships, Trophies..etc for simplicity. I need help with why order by and <> can’t output the correct answer. Am I doing something wrong here?

Thank you for the help in advance,

Advertisement

Answer

select player_name, jersey_number from Players order by jersey_number desc;

select player_name, player_age from Players where player_age < 30;

–DONT USE QUOTES IN ORDERBY–

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement