MySQL Forums
Forum List  »  Newbie

Re: Select an array from one databank and compare it to one from another databank
Posted by: Frank Olschewski
Date: November 27, 2015 12:57PM

Hey Barry,

thanks for the explanations, really helped me!
I am currently trying to figure out how to write the command that inserts the input into the right tables.
So for example, if there is a request from Mr. Black for bass and, after that, he also sends a request for guitar, I would have to exclude the subject id from the request table, to make it work, right?

So, I would create the requests table with -> request_id, name, street, phone number (no subject_id)
the table with the subjects -> subject_id, subject
a requests_subjects table with -> id, request_id, subject_id

So now, if a request is coming in, the following has to be done (as far as I planned it out):
1. First of all, insert the input into the request table -> request_id, name, street, phone
2. Select the request_id from the requests table where name = $_POST['name'] (in order to get the right request_id to insert it into the requests_subjects table)
3. Insert into the requests_subjects table with the request_id that has been selected before, so it is possible to have more than one subject from one request

So the problem I see here is that I use three commands (INSERT INTO -> requests, then SELECT -> the request_id for the next able, and finally -> INSERT INTO the requests_subjects table (for which I need the request_id).

So does that actually make sense or do I miss something there?
If it is right, I would implement that code and would use a similar code for the applicants forms/tables (if they send a form with more than one subject they can teach).

I hope I explained that correctly :p.

Best regards,
Frank

Options: ReplyQuote




Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.