简体   繁体   中英

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

table A:-

  a_id(p_k) | data1 | data2 
    1         xxx      yyy  

table B:-

  b_id(p_k) | bbb1 | bbb2  
    1         xxx     yyy

table 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...

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.

try this: use the 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM