A
A
Alexander2017-06-16 11:38:39
PHP
Alexander, 2017-06-16 11:38:39

How to write a simple query with IF ELSE in MySQL?

Please write an example.
What I want:
if my SELECT query finds a unique ID, then I don't make an INSERT query. If it does not find it (the query returns nothing), then I make an INSERT query.
I don’t want to set a condition in php and make two requests, but immediately write everything in one for optimization.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Anton, 2017-06-16
@Fragster

insert ignore? Or something more difficult?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question