sql select statement giving column error

前端 未结 3 1600
眼角桃花
眼角桃花 2021-01-28 09:59

When i use

SELECT order_id from `order` where `order_id`=U687678601

i get error

ERROR 1054: Unknown Column \'U68767

3条回答
  •  天命终不由人
    2021-01-28 10:07

    When we are supplying a string/varchar type to the SQL query we must specify it with the ''. and for the non varchar types no need to supply ''. Thats why your query works fine when u write

    SELECT order_id fromorder where order_id='U687678601'
    

    this shows that your order_id column contains the varchar type. so from now you should apply the following syntax to the SQL query:

    SELECT column_name,..... FROM table WHERE column_name = 'varchar_value'
    

    or

    SELECT column_name,..... FROM table WHERE column_name = nonvarchar_value.
    

    and also consider that the ORDER is the reserved keyword .. so try to change the table name to other like order_table or else...

提交回复
热议问题