GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   Tech Whats this called? (https://gfy.com/showthread.php?t=1359482)

Publisher Bucks 11-22-2022 03:33 AM

Whats this called?
 
I have two tables in the same SQL database that I want to pull information from (and have a user id in a hidden form field) so that when my writers submit documents through my admin system, it gets automatically tagged in the documents table with their user id.

Would that be creating a 'union' or is it something else?

Database Name
Table 1 - User Registration - I want to pull registered user ID from here.
Table 2 - Document Uploads - And attach it to the form upload when this is submitted.

Also, if it is a union, am I able to put an array on a page that will pull fields from both tables or just one?

TIA for any feedback :)

redwhiteandblue 11-22-2022 07:14 AM

No it's not a union.

You need to decide the relationship between the two tables. If only one user can ever be the author of a document, you just need a column in the document table containing the user id of that user.

If more than one user can contribute to a document you need a relational table. This would be another table with two columns, one for the document id and another for the user id. You add a row in this table for each user who contributed to each document. This allows you to have as many relationships between users and documents as necessary.

You then pull out the data with two joins statements in your query.

Publisher Bucks 11-22-2022 09:48 AM

Quote:

Originally Posted by redwhiteandblue (Post 23064432)
No it's not a union.

You need to decide the relationship between the two tables. If only one user can ever be the author of a document, you just need a column in the document table containing the user id of that user.

If more than one user can contribute to a document you need a relational table. This would be another table with two columns, one for the document id and another for the user id. You add a row in this table for each user who contributed to each document. This allows you to have as many relationships between users and documents as necessary.

You then pull out the data with two joins statements in your query.

Cheers, much appreciated :thumbsup


All times are GMT -7. The time now is 05:37 AM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc