Results 1 to 7 of 7
  1. #1

    Unhappy Need help MYSQL Query on dynamic table..


    Need help MYSQL Query on dynamic table..., been doing for almost a week but still it didn't work!, im using PHP5 and MYSQL, im using PS_Pagination class script that paginates my table, that's why im restricted to do it in one line of query... below is an example of what my specs is...

    e.g.
    DB_LIST.DBID => database/table
    ID DBID
    1 100
    2 300

    USER_100.account => database/table
    ID name
    1 Name1
    2 Name2

    USER_200.account => database/table
    ID name
    1 Name1
    2 Name2

    Query:
    'SELECT account.name FROM DB_LIST.DBID INNER JOIN USER_{DBID}.account ON account.id=DBID.accountid'

    any help will be appreciated!!!

  2. #2
    The main problem of this is your database structure.
    Just create one table "accounts" with the following fields: dbid, id, name

    Then you could do the select easily:
    SELECT account.name
    FROM account
    INNER JOIN db_list ON db_list.dbid = account.dbid

  3. #3
    that's the problem im not allowed to change the DB structure, they want it AS IS, i guess i hit a dead end on this one!!!

  4. #4
    C.I.A. Platinum Member carmicael's Avatar
    Join Date
    Jul 2007
    Gender
    Male
    Posts
    2,142
    most probably naay anomaly ang structure sa database. try reading "database anomalies" sa net. cheers.

  5. #5
    anomaly?, you mean a bug on the database engine itself?

  6. #6
    bro,

    why not create a stored procedure for this? from you db design, the only link between your account tables and dbid tables is thru the account table name which I think cannot be made variable inside a query or can it?

    but then again, it is still wise to take cold_fusion's suggestion since if you add another entry in your dbid table, you'll probably need to create another account table... that is not a good db design right?

  7. #7
    C.I.A. Platinum Member carmicael's Avatar
    Join Date
    Jul 2007
    Gender
    Male
    Posts
    2,142
    by anomaly i mean something present in the structure of your database, not something with the dbase engine itself. cheers.

  8.    Advertisement

Similar Threads

 
  1. Need Help: No Audio on Youtube
    By |nCuBabE in forum Networking & Internet
    Replies: 11
    Last Post: 11-12-2010, 10:06 AM
  2. Need HELP: Honest Opinion on Daihatsu Move
    By 7th in forum Automotive
    Replies: 7
    Last Post: 11-14-2009, 10:44 AM
  3. NEED HELP ... PC turns on by itself when AVR is switched on
    By yarniwre in forum Computer Hardware
    Replies: 9
    Last Post: 10-11-2009, 11:27 PM
  4. Need help, dll error on startup and cant delete trojan
    By Zuan in forum Software & Games (Old)
    Replies: 3
    Last Post: 03-04-2008, 10:50 PM
  5. NEED HELP - Unhiding Harddrives on the Desktop
    By kazki in forum Software & Games (Old)
    Replies: 4
    Last Post: 01-21-2008, 09:31 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
about us
We are the first Cebu Online Media.

iSTORYA.NET is Cebu's Biggest, Southern Philippines' Most Active, and the Philippines' Strongest Online Community!
follow us
#top