V
V
Vladimir Golub2018-02-28 14:56:57
SQL
Vladimir Golub, 2018-02-28 14:56:57

How to select all records if the WHERE condition is not received?

For example, there is a request
SELECT * FROM tabletest WHERE id=1
id that comes as a parameter, how to leave the same request structure, but select all values. Is there a replacement * in the condition.
For example
SELECT * FROM tabletest WHERE id=*

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Aksentiev, 2018-02-28
@RazerVG

build normally requests with the help of builders and not suffer.

A
Andrey Tsvetkov, 2018-02-28
@yellow79

Alternatively, you can use the OR condition. But in this case, you will have to pass the same id twice in the request. You will get something similar to this:
SELECT * FROM tabletest WHERE id=? OR '*'=?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question