Saturday 15 May 2010

How to Retrieve data from Multiple Tables in MySQL single Query? -


I have a database where the tables are as follows:

Table name: userDB < / Code>
Column name: user_id (customer ID), reseller_id (reseller who has contact with customer)

Name: ServerDB
Column name: server_id (server id), status (position above or below - if below 1 if 0 UP)

Table Name: Usage DB_University
My name: user_id (customer ID), server_id (server id)


table name: use db_desus Column name: user_id (customer ID), server_id (server id)
Note: useDB_january < There are 12 tables from / code> to useDB_december .

In a PHP page, I type server_id which is at the bottom (position 1)

__ < Em> _ __ _ __ _ __ _ __ _ __ _ __ _ __ _ __ _ __ _ __ _ __ _ __
| Serial no | Server ID below.
1 | 28839 |
2 | 20283 |
_ __ _ __ _ __ _ __ _ __ _ __ _ __ _ __ _ __ _ __ _ __ _ __ _ _

While I want that the resellers under that server ID To show the list.

I'm not understanding how to write a MySQL query.

Can you please help me? please?

I have no way of changing the database table structure. I can not understand the query.

Select reseller_id
to userDB
WHERE user_id = (
select User_id from to useDB_january
ou server_id like '17, 090 union
selection
User_id
to useDB_feb Feb
WHERE server_id as of '17090'
);

Error: # 1242 - Subquery returns more than 1 line

You can use it for your questions:

  Select user_id, server_id, useDB_january to reseller_id, join userDB, useDB_january.user_id = userDB.user_idUnion Selection user_id, server_id , Reseller_id useDB_free Join with UserDB on usageDB_february.user_id = userDB.user_idUnion // ... all other months    

No comments:

Post a Comment