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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T13:42:12+00:00 2026-06-13T13:42:12+00:00

I need to get all back up tables that are associated with their base

  • 0

I need to get all back up tables that are associated with their base table.
For example, table_name yields table_name_backup1, table_name_backup2 ..etc. The reason for doing this is because I don’t want to get backup tables names manually, there could be dozens of them and they are named based on game week and date and therefore their names cannot be predicted.

The result I get after executing this statement if $tbl = ‘ranking’ for example:

…

function getTables($tbl){
  $query = "SHOW TABLES LIKE '" . $tbl . "_gw%' ORDER BY ";

Result

 [0] => ranking_gw0_231012
    [1] => ranking_gw10_231012
    [2] => ranking_gw11_231012
    [3] => ranking_gw1_231012
    [4] => ranking_gw2_231012
    [5] => ranking_gw3_231012
    [6] => ranking_gw4_231012
    [7] => ranking_gw5_231012
    [8] => ranking_gw6_231012
    [9] => ranking_gw7_231012
    [10] => ranking_gw8_231012
    [11] => ranking_gw9_231012
    [12] => ranking       // I insert this manually before return statement. 

Everything is ok except that the order is not correct for tables with more than 9 backups, since table gw10 appears in index 1 and therefore, shows wrong data order when I submit their values.

I have been thinking to make a function that will extract the number in gwx and re sort the whole thing, but i think there must be a simpler way.

So, how could I show these tables in their correct order?

BTW, when i view my db in MYSQLYOG, they appear in that same exact order, while in my phpmyadmin they are shown in correct order, gw11 is shown the last one.
There is a possibility to have two tables with same gwx value, e.g ranking_gw0_080812 and ranking_gw0_101012

  • 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-13T13:42:14+00:00Added an answer on June 13, 2026 at 1:42 pm

    You should do something like:

    select table_name from information_schema.tables 
      where table_schema="yourDbName" and table_name like '" . $tbl . "_gw%' 
      order by create_time;
    

    Since you need only the tables that match a specific pattern, ordered by the time of creation.

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

Sidebar

Related Questions

I need to get all the appointments from my table for a particular patient,
I am developing a Facebook Application that I need to get all the information
I need get all items these have no categories int? categoryId = null; var
I need to get all the objects whose id matches a specific pattern .
I need to get all controls inside a specific RowDefinition/ColumnDefinition without iterating through all
I need to get all substrings from string. For ex: StringParser.GetSubstrings([start]aaaaaa[end] wwwww [start]cccccc[end], [start],
I need to get all characters between '(' and ')' chars. var str =
In C# i need to get all values of a particular property from an
I'm writing a custom admin stuff and need to get all registered models in
Title pretty much describes it, I just need to get all the order numbers

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.