简体   繁体   English

如何在SQL中使用存储过程从所有表中获取所有记录

[英]How can i get all records from all tables using stored procedure in my sql

table A:- 表A:-

  a_id(p_k) | data1 | data2 
    1         xxx      yyy  

table B:- 表B:-

  b_id(p_k) | bbb1 | bbb2  
    1         xxx     yyy

table C:- 表C:-

   c_id |  cc1 | ccc2 |a_id (F_K-Table A)  | b_id (F_K-Table B) 
     1      xx   yy     1                      1

Question - I want such a stored proceduer to get all data from A, B ,C table which are present in C table... 问题-我希望这样的存储过程从C表中存在的A,B,C表中获取所有数据...

I have Java Entities for A, B, C... In C table i have used ManyToOne for A. In C table i have used ManyToOne for B. 我有Java实体用于A,B,C ...在C表中,我对A使用了ManyToOne。在C表中,我对B使用了ManyToOne。

try this: use the inner join 试试这个:使用inner join

SELECT 
A.data1,A.data2,
B.bbb1,B.bbb2,
C.cc1,C.cc2
FROM TABLE A
INNER JOIN TABLE C
ON A.a_id =C.a_id 
INNER JOIN TABLE B
ON B.b_id=C.b_id

You need JOIN 你需要加入

SELECT A.*,B.*,C.*
FROM tableA A
INNER JOIN tableC C
ON A.a_id =C.a_id 
INNER JOIN tableB B
ON B.b_id=C.b_id

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 打印所有学生记录时,如何使我的程序恢复正常? - How can I get my program back on track when printing out all student records? 如何从我的 android 设备中获取所有照片 - How can I get all photos from my android device 如何查看存储在 ArrayList 中的所有元素? - How Can I see all of the elements stored in my ArrayList? 我有一个来自 SQL Server 存储过程的 ArrayList,我想将所有数据插入 SQLite 数据库。 请看我下面的代码 - I have an ArrayList coming from SQL Server stored procedure and I want to insert all the data to a SQLite database. Please look at my code below 如何在休眠状态下使用join从三个表中获取记录? - how can get records from three tables using join in hibernate? 我如何将所有logcat条目存储到android中的文件 - How can i get all logcat entries stored to a file in android 如何使用HQL / Hibernate验证我的所有表都为空? - How can i verify that all my tables are empty with HQL/Hibernate? 如何使用分页和 spring data jpa 获取 findAll () 服务的所有记录? - How can I get all the records for findAll () service using pagination and spring data jpa? 如何使用 Java 从网站获取所有 cookie - How can I get all cookies from a website using Java 如何获得JavaDB数据库中所有表的名称? - How can I get the name of all tables in a JavaDB database?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM