NULL value
In SQL, Null means nothing at all. This is not 0, it's NULL. When a field is 0, it is included in calculations, but when it's NULL, it's completely excluded from calculations. If you want to exclude Null in the result, you can use Where and is not null query. select a.order_id, a.customer_id, a.restaurant_name, a.price, b.name, b.age, b.genderfrom food_orders..
2024. 3. 22.
Table name from Subquery [SQL]
I was looking for the column "age" from table B, but when I used "b.age", it resulted in an error. Error code SELECT a.cuisine_type, a.price, 할인률, b,age, a.price-(price*할인률) 'after_discount' FROM ( SELECT a.cuisine_type, a.price, b.age, if(b.age>50,(b.age-50)*0.005,0) '할인률' from food_orders a left join customers b on a.customer_id=b.customer_id ) a order by 할인률 desc The error occurred because th..
2024. 3. 21.
Red highlighted error [SQL]
I received an error message, but the result is fine. I can't find any issues, but the SQL system highlighted the word. SELECT a.cuisine_type, a.price, discount, age, a.price-(price*discount) 'after_discount' FROM ( SELECT a.cuisine_type, a.price, b.age, if(b.age>50,(b.age-50)*0.005,0) 'discount' from food_orders a left join customers b on a.customer_id=b.customer_id ) a order by discount desc
2024. 3. 21.