1

Topic: If there is in basis of correspondence that to return 0 if there is no that to fulfill request.

Hello, at once I will tell that I am not strong in MySql and if something turns out that only a trial and error method, therefore I write here . at all I do not know from what side to approach.
In basis there are 3 columns ip (PRIMARY VARCHAR), time (INT), name (VARCHAR)
I need to make one request check and request if check transited.
If in basis is ip (192.168.0.1) and time> = it is necessary to return 1502324324 that 0 (to inform the program) if the condition did not transit check that it is necessary to change time = 15 and name - ' Kohl '.
And if allow 2 problem:
If in basis is ip (192.168.0.1) and time <1502324324 that it is necessary to delete this record from the table.
Very much I calculate for the specific help in an example and it is desirable with the explanation. Thanks.

2

Re: If there is in basis of correspondence that to return 0 if there is no that to fulfill request.

I will correct myself, speaking to "basis" - had I will enter in the table.

3

Re: If there is in basis of correspondence that to return 0 if there is no that to fulfill request.

Nteee;

Nteee wrote:

If in basis is ip (192.168.0.1) and time <1502324324 that it is necessary to delete this record from the table.

delete from table 1
where ip = ' 192.168.0.1'
and time <1502324324

Nteee wrote:

If in basis is ip (192.168.0.1) and time> = it is necessary to return 1502324324 that 0 (to inform the program) if the condition did not transit check that it is necessary to change time = 15 and name - ' Kohl '.

..To change in WHAT record?

4

Re: If there is in basis of correspondence that to return 0 if there is no that to fulfill request.

In record which corresponds ip (192.168.0.1) is a unique record in the table.

5

Re: If there is in basis of correspondence that to return 0 if there is no that to fulfill request.

In the table clients there are 3 fields: ip (PRIMARY - unique), name, time
It is necessary to send request so that it did the following. If in the table is ip = 192.168.0.1 and time> 12345 that to do and return nothing the answer (Callback) = 0 and if the condition is fulfilled that it is necessary to change time on 54321 and to change name = Kohl, then to return the answer (Callback) = 1;
It is necessary to consider. That in the table can be such ip, and can and not to be... Therefore it is important to consider singularities UPDATE and INSERT at request creation. (ON DUPLICATE KEY UPDATE - helps)
Very much I ask to help experienced users. Thanks.
Here I at one forum on php asked a question I can here is more clear explained the purpose!

6

Re: If there is in basis of correspondence that to return 0 if there is no that to fulfill request.

Nteee wrote:

In the table clients there are 3 fields: ip (PRIMARY - unique), name, time
It is necessary to send request so that it did the following. If in the table is ip = 192.168.0.1 and time> 12345 that to do and return nothing the answer (Callback) = 0 and if the condition is fulfilled that it is necessary to change time on 54321 and to change name = Kohl, then to return the answer (Callback) = 1;
It is necessary to consider. That in the table can be such ip, and can and not to be... Therefore it is important to consider singularities UPDATE and INSERT at request creation. (ON DUPLICATE KEY UPDATE - helps)
Very much I ask to help experienced users. Thanks.
Here I at one forum on php asked a question I can here is more clear explained the purpose!

where that is close, but all the same not 100 %.  time -
At you 2 or 3 variants or how many?
1. 192.168.0.1 is and time> 12345 (a name it is not important) - to return (0)
2. 192.168.0.1 is and time> 12345 (the name is not important) -   12345 and a name pricking
3. Records 192.168.0.1 are not present - is done that?
4. There are some records with 192.168.0.1 - is done that?
Whether 2 the task is connected to the task 1?

7

Re: If there is in basis of correspondence that to return 0 if there is no that to fulfill request.

3. Records 192.168.0.1 are not present - is done that? - That we add it with instructions time 34321 and name - Kohl
4. There are some records with 192.168.0.1 - is done that? - And here such should not be . this unique field. And in basis it is marked as unique - PRIMARY
The task 1 and the task 2 are not connected among themselves.

8

Re: If there is in basis of correspondence that to return 0 if there is no that to fulfill request.

Nteee wrote:

3. Records 192.168.0.1 are not present - is done that? - That we add it with instructions time 34321 and name - Kohl
4. There are some records with 192.168.0.1 - is done that? - And here such should not be . this unique field. And in basis it is marked as unique - PRIMARY
The task 1 and the task 2 are not connected among themselves.

...Is not present with one blow such task on MSQL not to solve
(On  the Server - it is possible).
decisions - some requests in transaction:
* To begin transaction
* INSERT IGNORE.... - there will be a pure insertion at 
* UPDATE TABLE tbl
set time = 12345;
name = ' Kolia'
WHERE ip = ' 127.0.0.1'
and time <12345
* commit

9

Re: If there is in basis of correspondence that to return 0 if there is no that to fulfill request.

IP it is better to store in INT: SELECT INET_ATON (' 192.168.2.1 ');
And it is reverse: SELECT INET_NTOA (INET_ATON (' 192.168.2.1 '));
And here time is better for storing in TIMESTAMP or DATE

10

Re: If there is in basis of correspondence that to return 0 if there is no that to fulfill request.

In  - ip2long ()