Hello:
Hopefully someone can help me with an SQL join statement that can work for me.
Basically what I want to do is this:
Pull the file_name's from the files table for all file_name's in the table that have a link_id of say 50. Easy enough
Then the part I am stumped on:
Lets say there are 5 files with a link_id of 50 in the files table. Each of those files has a unique file_id say 1-5. Now I want to join the approvals table for those file_id's that correspond with those in the files table. files.file_id = approvals.file_id. Does anyone have any ideas for me? Im I structuring this properly in the database?
Here are my table structures if that helps:
Files Table
+-----------------+------------------+------+-----+---------------------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-----------------+------------------+------+-----+---------------------+----------------+
| file_id | int(10) unsigned | | PRI | 0 | auto_increment |
| link_id | int(10) unsigned | | MUL | 0 | |
| file_name | varchar(50) | | | | |
Approvals Table:
+-----------------+------------------+------+-----+---------------------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-----------------+------------------+------+-----+---------------------+----------------+
| app_id | int(10) unsigned | | PRI | 0 | auto_increment |
| file_id | int(10) unsigned | | MUL | 0 | |
| account | varchar(50) | | | | |
Thanks for the help!
Troy
Hopefully someone can help me with an SQL join statement that can work for me.
Basically what I want to do is this:
Pull the file_name's from the files table for all file_name's in the table that have a link_id of say 50. Easy enough
Then the part I am stumped on:
Lets say there are 5 files with a link_id of 50 in the files table. Each of those files has a unique file_id say 1-5. Now I want to join the approvals table for those file_id's that correspond with those in the files table. files.file_id = approvals.file_id. Does anyone have any ideas for me? Im I structuring this properly in the database?
Here are my table structures if that helps:
Files Table
+-----------------+------------------+------+-----+---------------------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-----------------+------------------+------+-----+---------------------+----------------+
| file_id | int(10) unsigned | | PRI | 0 | auto_increment |
| link_id | int(10) unsigned | | MUL | 0 | |
| file_name | varchar(50) | | | | |
Approvals Table:
+-----------------+------------------+------+-----+---------------------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-----------------+------------------+------+-----+---------------------+----------------+
| app_id | int(10) unsigned | | PRI | 0 | auto_increment |
| file_id | int(10) unsigned | | MUL | 0 | |
| account | varchar(50) | | | | |
Thanks for the help!
Troy