mysql数据库中有3个表,例如这样
只知道表3中的s相的数据
要达到select * from 表1 where 1= ;
的效果怎么弄?用存储过程达成这个效果,求解。。

解决方案 »

  1.   

    无法理解这个问题想表达的是什么。
    (不要高估你的汉语表达能力或者我的汉语理解能力)[/color]
       建议你列出你的表结构,并提供测试数据以及基于这些测试数据的所对应正确结果。
       参考一下这个贴子的提问方式http://topic.csdn.net/u/20091130/20/8343ee6a-417c-4c2d-9415-fa46604a00cf.html
       
       1. 你的 create table xxx .. 语句
       2. 你的 insert into xxx ... 语句
       3. 结果是什么样,(并给以简单的算法描述)
       4. 你用的数据库名称和版本(经常有人在MS SQL server版问 MySQL)
       
       这样想帮你的人可以直接搭建和你相同的环境,并在给出方案前进行测试,避免文字描述理解上的误差。
      

  2.   

    举例说明要求
    贴建表及插入记录的SQL,及要求结果出来看看
      

  3.   

    额、、、是这样的3个表
    Create table distribution(
    C_id int(10) not null primary key,
    S_id int(10)
    );
    Create table staff(
    S_id int(10) not null primary key,
    Name varchar(10),
    Gender varchar(10),
    Age int(10),
    Way_of_contacr varchar(20)
    );
    Create table computer(
    C_id int(10) not null primary key,
    Brand varchar(20),
    Hardware varchar(50),
    Software varchar(20),
    Buying_time date,
    If_repair varchar(10),
    Distribution varchar(5)
    );
    然后用一个存储过程达到:输入staff表中的name项通过查询staff表中S_id然后用S_id查询distribution表中对应的C_id再返回computer表中对应C_id的所有内容。。这么说可以么?还有问题的话请提出来我再详细点
      

  4.   

    select * from staff a inner join distribution b on a.S_id=b.S_id
    inner join computer c on b.c_id=c.c_id
    where a.name='你的要求'
      

  5.   

    用了你的以后显示的是这个结果
    +------+------+--------+------+----------------+------+------+------+-------+---
    -------+----------+-------------+-----------+--------------+
    | S_id | Name | Gender | Age  | Way_of_contacr | C_id | S_id | C_id | Brand | Ha
    rdware | Software | Buying_time | If_repair | Distribution |
    +------+------+--------+------+----------------+------+------+------+-------+---
    -------+----------+-------------+-----------+--------------+
    |    3 | Jack | NULL   | NULL | NULL           |    1 |    3 |    1 | NULL  | NU
    LL     | NULL     | NULL        | used      | NULL         |
    +------+------+--------+------+----------------+------+------+------+-------+---
    -------+----------+-------------+-----------+--------------+
    这个是3个表都显示了,但是我想只显示出computer那一个表的内容怎么办?
      

  6.   

    select c.* from staff a inner join distribution b on a.S_id=b.S_id
     inner join computer c on b.c_id=c.c_id
     where a.name='你的要求'