0

I am using MariaDB 10.1.37. I have a Test table with a field called delete which is of type bit

+---------+------------------+------+-----+---------+----------------+
| Field   | Type             | Null | Key | Default | Extra          |
+---------+------------------+------+-----+---------+----------------+
| id      | int(11) unsigned | NO   | PRI | NULL    | auto_increment |
| user_id | int(11) unsigned | NO   | MUL | NULL    |                |
| email   | varchar(255)     | NO   |     |         |                |
| delete  | bit(1)           | NO   |     | b'0'    |                |
+---------+------------------+------+-----+---------+----------------+

As per https://mariadb.com/kb/en/library/bit/, delete+0 should show me teh value. But it does not.

select delete+0 from Test;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'delete+0 from blacklist' at line 1```

Would appreciate if anyone can tell how I display the bit field type instead.

Praveen
  • 1,781
  • 6
  • 26
  • 32
  • 1
    `DELETE` is a [MySQL reserved word](https://dev.mysql.com/doc/refman/8.0/en/keywords.html). You need to enclose it in backticks to use it in a query – Nick Apr 23 '19 at 14:31
  • indeed @Nick ideally you should not be using SQL reserved words and enclose it with backticks but rather prefix or suffix it with a other a word that works more or less like a "namespace" for example `record_delete` or `soft_delete` . But that's a matter of taste or opinion – Raymond Nijland Apr 23 '19 at 14:51
  • @RaymondNijland you had me at "you should not be using SQL reserved words"! :-) – Nick Apr 23 '19 at 21:13

0 Answers0