O
O
ortsuev332018-12-28 22:41:17
PHP
ortsuev33, 2018-12-28 22:41:17

How to make it better to implement a double request?

There are two tables in the database, at the beginning I need to compare the numbers that come from the user, there may be 1-20 of them, plus they can be the same (I immediately say in is not suitable because if there are two identical numbers, in will return their result as one) if there were no errors in the database, the selection was successful, I make a second request to insert these numbers.
1 question how to do without in so that all matches are returned or not one,
2nd how to make a request so that there are not several of them, I hope I explained clearly

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alex, 2018-12-28
@ortsuev33

If I understand correctly, based on user input, you need to get records from the database. Moreover, if there are several identical numbers in the input, then the records must be obtained by the number of these numbers. Even if it is possible, it is very suboptimal, because the data in these rows will be exactly the same. It is much easier to get data from the database and then rebuild it into the desired structure in the code.
As for the ability to do this with a single query... Well, you can do something similar to a single query: if the database supports batch queries, then you can add several queries to one line and send them. Or make a stored procedure. About the existence of a mechanism that, based on the success of the selection, would make insert in one request - I have never heard

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question