Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8643089
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T11:56:45+00:00 2026-06-12T11:56:45+00:00

i am using ORDER BY in mysql SELECT query but i dont know ots

  • 0

i am using ORDER BY in mysql SELECT query but i dont know ots not ordering the data.. if i use this query its showing the table but not ordering the data in ascending order

$result = mysql_query("SELECT *FROM learningmaterial ORDER BY 'order' ASC")or   die(mysql_error()); 

but if i use

$result = mysql_query("SELECT *FROM learningmaterial ORDER BY order ASC")or die(mysql_error()); 

then it give error that the syntax of the query is not right…i’ve seen on various sites but i couldnot found anything unique in my code…i think its right,…please check the query and mend a solution. Thankx in advance 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T11:56:46+00:00Added an answer on June 12, 2026 at 11:56 am

    You need backticks, not single quotes (a):

    ... SELECT * FROM learningmaterial ORDER BY `order` ASC ...
    

    By using single quotes, you’re ordering the rows by a constant (each row gets the same constant) so effectively not ordering them at all.

    By using a “naked” column name of order, you’re confusing the SQL parser, since order is a reserved word.


    (a): Of course, this problem goes away if you stop using reserved words as column names but I assume you did that for a reason (such as a bucket-load of programs already depending on the fact that the column is called order).

    Myself, I tend not to use generic names for columns (such as order or date), preferring instead things that don’t conflict with the language (such as order_num or start_date). That way I don’t have to worry about escaping.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For fetching records from a table I use this mysql query: SELECT a.id as
I know I can change the way MySQL executes a query by using the
I am using GROUP_CONCAT in mysql query but the query gives me unexpected and
I'm trying to optimize this mysql query using EXPLAIN. Can somebody please help me
I try to bind a NSString value into my SQL query but its not
I have a mysql query that I thought should be using my indexes but
I am using mysql_query(INSERT INTO imaegs_backup SELECT * FROM images); in order to copy
To order by name I'm using 'order by name ' But the names contain
I'm using PHP in order to redirect some search query. There is some example
I have this PHP code : $query = SELECT * FROM news WHERE news_active

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.