Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Table column name is 'default'

I'm having a hard time querying a table which has a column name 'default', it shows an error, I can't rename it because I'm using an old system and it might affect our previous systems.

e.g.

select * from table_name where default = 1

tried this

select * from table_name where 'default' = 1

and it didn't work.

Is there a workaround on this?

like image 241
Kelvin Barsana Avatar asked Jun 10 '15 09:06

Kelvin Barsana


People also ask

What is a default column?

Certain columns and data types have predefined or assigned default values. For example, default column values for the various data types are as follows: NULL. 0 Used for small integer, integer, decimal, single-precision floating point, double-precision floating point, and decimal floating point data type.

What is default in SQL table?

The DEFAULT constraint is used to set a default value for a column. The default value will be added to all new records, if no other value is specified.

How do I set default columns?

Select the column for which you want to specify a default value. In the Column Properties tab, enter the new default value in the Default Value or Binding property.

What is a default value for a column of a table in SQL?

When using CREATE TABLE , you can specify default values for columns by typing DEFAULT and then the desired value after it. If a row is inserted that does not specify a value for that column, the database will fill it in with the default value instead.


1 Answers

You should use backtips:

select * from table_name where `default` = 1
like image 179
Mathlight Avatar answered Sep 28 '22 07:09

Mathlight