Can we use backticks with column value in MySQL?

MySQLMySQLi Database

You cannot use backticks with column value. For this, use only table name or column name. If you use backtick with column value then MySQL will give the following error message:

ERROR 1054 (42S22): Unknown column '191.23.41.10' in 'where clause'

Let us first create a table:

mysql> create table DemoTable6
(
   SystemIPAddress varchar(200)
);
Query OK, 0 rows affected (0.46 sec)

Following is the query to insert some records in the table using insert command:

mysql> insert into DemoTable values('192.68.1.0');
Query OK, 1 row affected (0.19 sec)
mysql> insert into DemoTable values('191.23.41.10');
Query OK, 1 row affected (0.12 sec)

Now you can display specific record from the table using select statement:

mysql> select *from DemoTable where SystemIPAddress=`191.23.41.10`;

This will produce the following output i.e. an error since we used backtick with column value:

ERROR 1054 (42S22): Unknown column '191.23.41.10' in 'where clause'

Let us see the correct way to display the same record:

mysql> select *from DemoTable where SystemIPAddress='191.23.41.10';

This will produce the following output:

+-----------------+
| SystemIPAddress |
+-----------------+
| 191.23.41.10    |
+-----------------+
1 row in set (0.00 sec)
raja
Published on 29-Apr-2019 07:53:25
Advertisements