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

  • SEARCH
  • Home
  • 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 8457833
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T12:54:47+00:00 2026-06-10T12:54:47+00:00

I do have a question or maybe misconception about seraching in Mysql. In my

  • 0

I do have a question or maybe misconception about seraching in Mysql.


In my table I have 2 fields, first’s ID (int 8) and second’s used (int 1).

The used field just get 0 or 1 like boolean.

Assuming the number of rows’s 20001,

about ID: My last ID is 20001 and first ID’s 1.

about used: Just my first row which has ID = 1 is 1 and the others is 0.

Now when I wanna get one row, I write this code.It’s OK.

 SELECT * 
 FROM  `table` 
 WHERE  `used` =0
 LIMIT 0 , 1

I just want a row with 0 amount in used.
But my problem is : I imagine, Mysql search all of the 20000 rows, and so give me one row. This will hurt me because I just want one row with 0 amount in used
what’s the best way for doing?

  • 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-10T12:54:48+00:00Added an answer on June 10, 2026 at 12:54 pm
    SELECT * FROM table_name WHERE used = "0";
    

    Will give you all rows which used value is 0, with:

    SELECT * FROM table_name WHERE used = "0" LIMIT 1;
    

    Will give you one row which used value is 0.

    If this is not what you are looking for, can you clarify your question?

    If you need the last record

    SELECT * FROM table_name WHERE used = "0" ORDER BY id DESC LIMIT 1;
    

    Edit:

    If you are worried about speed of your queries I suspect that if you start up your mysql via command line (or tool you prefer) and run queries provided to a table with only that much records you will get sentence saying how long it will take, it might say (0.00 sec) if its absolutely nothing. 🙂

    If your table gets more complicated consider learning to use mysql indexes for certain columns: http://dev.mysql.com/doc/refman/5.0/en/mysql-indexes.html

    About reserved words in MySQL:

    Your table naming caught my attention and you should consider of using something other than table as table name so you don’t need to use quotation marks around table word when using it. (you are also using them around word used which is not even reserved word.

    List of reserved words which should be avoided to be used within MySQL(5.5): http://dev.mysql.com/doc/refman/5.5/en/reserved-words.html

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

Sidebar

Related Questions

I have a question about strange return sizes when calling GetUserNameEx(). Maybe someone has
I have a question about using session, or maybe TempData to store data while
I have a question about duplicate Hashtables in Java (maybe duplicate Java Collections). My
I have a question about video streaming from Android devices and maybe someone who
I have a question about righteous way of programming in Python... Maybe there can
A question to maybe some who have worked extensively with WinUSB APIs or user
I have a simple question, but searching on the internet didn't help me (maybe
I have some questions, maybe stupid question. I have this url: http://flibusta.net/opds/opensearch?searchTerm=Тол&searchType=books and I
A short, maybe stupid question. For classes and structs, sometimes I like to have
Maybe a basic question but let us say I have a string that is

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.