H
H
Higrok2020-05-13 13:10:19
PHP
Higrok, 2020-05-13 13:10:19

How to correctly make a request?

Hello.

I sit and puzzle over how to correctly compose a request. There is a task to display from the database all records whose value of the user_id column matches the id of the registered user, but in addition, you need to take into account that if user_id is equal to 0 , then such records should also be displayed along with those that matched the condition above (if any are available).

A little confusing for me, but I hope I explained it clearly.

How to do it?

Code currently available: https://pastebin.com/fK2FmURY

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Rsa97, 2020-05-13
@Higrok

WHERE `user_id` = :id OR `user_id` = 0
Or via UNION

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question