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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T11:42:26+00:00 2026-06-01T11:42:26+00:00

I have a bunch of tables that are like Client# and the # changes.

  • 0

I have a bunch of tables that are like Client# and the # changes. Is there a way to create a query to query that table based on the client number you get from logging in as their use?

Example to give idea:

      $q2 = "SELECT * FROM users WHERE username = '".$_SESSION['username']."'";
        $result2 = mysql_query($q2,$conn);
        $row = mysql_fetch_assoc($result2);
        $_CLIENT_ID = $row['CLIENTID'];
        $q2 = "SELECT * FROM client+".$_CLIENT_ID."";

Is there a better way to do this?

I’m trying to keep clients in their own tables so they do not get to massive.

  • 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-01T11:42:27+00:00Added an answer on June 1, 2026 at 11:42 am

    I’m trying to keep clients in their own tables so they do not get to massive.

    This is almost always the wrong strategy. The table size isn’t as important as how you have indexed it for access, and it can be partitioned later, should that become necessary. The proper way to handle this is simply a column in one table which identifies the client id.

    With a proper client-identifying column you can query as:

    SELECT othertable.* 
    FROM
      users 
      JOIN othertable ON users.CLIENTID = othertable.CLIENTID
    WHERE users.username = '$_SESSION['username']'
    

    Dealing with dynamic table names becomes troublesome not only because it is more difficult to query against. You cannot, for example, use a placeholder in place of a table name with many parameterized query APIs like PDO & MySQLi:

    // Won't work with a PDO prepared statement.  :clienttable place holder isn't allowed
    SELECT * FROM :clienttable WHERE value=:someval
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have to create a query that compiles a bunch of data for each
So I have two seperate tables. In the first table, there are a bunch
I have a bunch of tables that have DateUpdated columns. How can I have
I have a table containing a bunch of input fields, sort of like a
I have a whole bunch of tables that were formatted weird, because when a
I'd like a query that at its simplest will join 2 tables together with
I have a series of table rows like this: <cfloop query=qryPlayer> (...snip...) <input data-playerid=#PlayerID#
Is there anyway to have a client side small database that syncs with server
I have a bunch of tables that I left join and a Group By
I have a bunch of tables that all have a field called ResourceID that

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.