0

現在、5つ以上のテーブルと大量のデータを含む大きなデータベースがあります。

データの行ごとに、フィールドの 1 つとしてユーザー ID があります。このようにして、どのデータがどのユーザーIDに属しているかを識別できるようにしています。

特定のユーザー ID を持つすべてのテーブルからすべてのデータを表示するにはどうすればよいでしょうか。

information_schema.tables を使用してすべてのデータを表示するオンラインで見つけたいくつかの例を試しましたが、特定のユーザー ID からのみ表示するにはどうすればよいですか?

4

4 に答える 4

0

this one will be achieved by the JOIN Queries . if u have any doubt please see this link.http://phpweby.com/tutorials/mysql/32 or o/w give me the table fields i will update.

and i hope this will help you..

for example,

1). mysql> SELECT * FROM products;
+----+--------------+--------------+
| id | product_name | manufacturer |
+----+--------------+--------------+
|  1 | Shoes        | Company1     |
|  2 | Laptop       | Company2     |
|  3 | Monitor      | Company3     |
|  4 | DVD          | Company4     |
+----+--------------+--------------+
4 rows in set (0.00 sec)





 2). mysql> SELECT * FROM buyers;

    +----+------+------------+----------+
    | id | pid  | buyer_name | quantity |
    +----+------+------------+----------+
    |  1 |    1 | Steve      |        2 |
    |  2 |    2 | John       |        1 |
    |  3 |    3 | Larry      |        1 |
    |  4 |    3 | Michael    |        5 |
    +----+------+------------+----------+

this will be the output.

mysql> SELECT buyers.buyer_name, buyers.quantity, products.product_name FROM buyer
s LEFT JOIN products ON buyers.pid=products.id where buyers.id=1;
+------------+----------+--------------+
| buyer_name | quantity | product_name |
+------------+----------+--------------+
|John        |        1 | Laptop       |
+------------+----------+--------------+
于 2013-04-02T11:13:00.677 に答える
0

mysql ステートメントで where 句を使用する必要があります

userid = this

これをあなたの声明の最後に置いてください

于 2013-04-02T10:57:59.590 に答える