I have two simple tables.
mysql> select * from filesshare;
+----+--------+--------+-------+
| id | userId | fileId | owner |
+----+--------+--------+-------+
| 1 | 2 | 1 | 1 |
| 2 | 3 | 1 | 1 |
| 3 | 4 | 2 | 1 |
| 4 | 5 | 2 | 1 |
+----+--------+--------+-------+
4 rows in set (0.00 sec)
mysql> select * from filesinfo;
+----+-----------------+-----------------------------------+
| id | name | url |
+----+-----------------+-----------------------------------+
| 1 | dwnld_btn.png | C:\shareapp\admin\dwnld_btn.png |
| 2 | dwnld_btn_1.png | C:\shareapp\admin\dwnld_btn_1.png |
+----+-----------------+-----------------------------------+
2 rows in set (0.01 sec)
i will have now two values as input. 1) userId 2) owner
now assume userId=3 and owner=1. Now i want out put to match all the rows with given values in filesshare table in this case its second row that is " 2 | 3 | 1 | 1 " now i want that column three value which is 1 now. Then with that value i want to retrieve the data from filesinfo table. in this case the first row of filesinfo table will b the output. like this:
+----+-----------------+-----------------------------------+
| id | name | url |
+----+-----------------+-----------------------------------+
| 1 | dwnld_btn.png | C:\shareapp\admin\dwnld_btn.png |
+----+-----------------+-----------------------------------+
is that possible using joins using hibernate, a simple example can be a kickstart for me.
i tried this
mysql> Select fileid,name,url from filesshare fs,filesinfo fi where fs.fileid=fi
.id;
+--------+-----------------+-----------------------------------+
| fileid | name | url |
+--------+-----------------+-----------------------------------+
| 1 | dwnld_btn.png | C:\shareapp\admin\dwnld_btn.png |
| 1 | dwnld_btn.png | C:\shareapp\admin\dwnld_btn.png |
| 1 | dwnld_btn.png | C:\shareapp\admin\dwnld_btn.png |
| 1 | dwnld_btn.png | C:\shareapp\admin\dwnld_btn.png |
| 2 | dwnld_btn_1.png | C:\shareapp\admin\dwnld_btn_1.png |
| 2 | dwnld_btn_1.png | C:\shareapp\admin\dwnld_btn_1.png |
| 2 | dwnld_btn_1.png | C:\shareapp\admin\dwnld_btn_1.png |
| 2 | dwnld_btn_1.png | C:\shareapp\admin\dwnld_btn_1.png |
+--------+-----------------+-----------------------------------+
Thanks and regards