Search code examples
mysqlsqlsql-like

Use * Like operator to search all columns of table in sql query


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.


Solution

  • 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"'.