0

Here I have a question if it is possible to search all columns of my table in database in query, not using Like operator to my each column as:

SELECT * FROM banquets WHERE bqtID LIKE '%Value1' OR bqtName LIKE '%Value2';

But I want to use * instead of using multiple Like operator with my columns as like(Is it possible?):

SELECT * FROM banquets WHERE * LIKE '%Value%';

Since I've not tested it, I just want to know if it's possible or not. If not then how can I accomplish it? Or what can be alternative of that thing?

Edit:

The question that is marked as duplicate is about using WHERE clause with mentioning all columns of table separately but I want to use it * in place of columns.

Cœur
  • 37,241
  • 25
  • 195
  • 267

1 Answers1

1

No, it's not possible.

Try it here: https://www.w3schools.com/sql/trysql.asp?filename=trysql_op_in with following request:

SELECT * FROM Customers WHERE * LIKE "%an";

You'll get:

Syntax error (missing operator) in query expression '* LIKE "%an"'.

Mr.Blob
  • 61
  • 5
  • how can I accomplish it? –  Oct 13 '17 at 16:11
  • I'm sorry but I guess there is no better way than doing: `SELECT * FROM Customers WHERE ContactName LIKE "%an" OR City LIKE "%an" OR ...;` – Mr.Blob Oct 13 '17 at 16:19
  • https://stackoverflow.com/questions/18415820/mysql-is-it-possible-to-use-like-on-all-columns-in-a-table – Mr.Blob Oct 13 '17 at 16:37
  • thanks for reply ... there is also providing columns **(`name`, `foo`, `bar`)** separately but I want to use `*` in place of columns. –  Oct 13 '17 at 16:41