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 8271065
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T06:45:09+00:00 2026-06-08T06:45:09+00:00

I’m a beginner at MySQL syntax. So there are a few question I want

  • 0

I’m a beginner at MySQL syntax. So there are a few question I want to ask.

I got a clue DB where users can add in clues. And have a webmethod that select a range of numbers to do random function. (random for the sake of the game, no point doing same clue over and over right?)

But my main problem right now is that what if the author decided to add in more clues?
then my clue db will be looking like this.

+--------+-------------+-----------+--------+
| cID    | clueDetails |  location | author |
+--------+-------------+-----------+--------+
|   1    |      abcde  |   loc 1   | auth 1 |
|   2    |      efghi  |   loc 1   | auth 1 |
|   3    |      jklmno |   loc 2   | auth 1 |
|   4    |      pqrstu |   loc 2   | auth 1 |
|   5    |      vwxyz  |   loc 1   | auth 1 |
+--------+-------------+-----------+--------+

If the player select loc1 auth 1, it will be showing cID 1,2 and 5. so I couldn’t use my random function effectively as it select the first and last of loc and auth and 3 and 4 doesnt fit in. I know right now it’s very vague as information are scarce. And to actually understand the whole process, goes right down to the game, and the method/function I have. (which will be very long)

Cutting to the chase, my result will be something as shown below, and the way to identify it will be by cID, but in the event that clue were added in different order ( as shown above) then my function will get rather screw up.

EDIT: assuming this random function give me back 2 clues, because I want to play 2 clues. this random function give me back 1 and 3. so from the table result below, 1 and 3 will give me cID1 and cID5 as they are row number 1 and 3. (sorry for the confusion caused)

+--------+-------------+-----------+--------+
| cID    | clueDetails |  location | author |
+--------+-------------+-----------+--------+
|   1    |      abcde  |   loc 1   | auth 1 |
|   2    |      efghi  |   loc 1   | auth 1 |
|   5    |      vwxyz  |   loc 1   | auth 1 |
+--------+-------------+-----------+--------+

So with that, I want to ask if can we select row by its number? e.g row[3] = cID 5, vwxyz, loc 1, auth 1.

As far as I’m concerned, I’ve done massive research and there doesn’t seem to be any function in MySQL that allow us to select by row number. (though all the article were pretty old dated, 2010 and before. Not sure if MySQL has added in any new function)

I saw a SO thread – MySQL – Get row number on select and from how I see it, it seems to be generating a field called ranking.

What I want to know is, is this field ranking temp or permanent? Because if it’s just a temp field, then I could shift the identifier from cID to this numbering.

Or do any of you have any suggestion to go around solving this issue? I thought of clearing the db, and re create the db, but that will be taking too much time. And over time when the DB get large it will be slower as well. And another method is to make a datatable to fill all the current clue where loc=?loc and auth=?auth and add them in again with the new clue(latest), but i figure that will cause the cID to boom and fly at a very fast rate. And I’m afraid this will cause memory management issue / memory leak.

EDIT2: As the create field is just a temp field, and seem to be the only alternative, I tried this MySQL command.

set @rank=0;
select @rank:=@rank+1 AS rank, cId, clueDetails, location, author from tbl_clue where location = "loc" and author = "auth" order by rank ASC

It seem to display what I want, but my command seem different from what other usually give. (more bracket and other stuff). Is my command ok? will there be any indirect implication caused by it?

  • 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-08T06:45:09+00:00Added an answer on June 8, 2026 at 6:45 am

    You can try this one. Please add a comment if this helps 🙂

    SELECT     cID, clueDetails, location, author
    FROM
       (
          SELECT    @rownum := @rownum + 1 as `RowNo`, 
                    p.cID, 
                    p.clueDetails, 
                    p.location, 
                    p.author 
            FROM (
                   SELECT cID, clueDetails, location, author
                     FROM myTableName
                    WHERE location = 'loc 1' AND author = 'auth 1'
                 ) p , (SELECT @rownum:=0) r 
        ) y
    WHERE y.RowNo = 3
    ORDER BY RowNo
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
i want to parse a xhtml file and display in UITableView. what is the
Does anyone know how can I replace this 2 symbol below from the string

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.