sql易錯點 和in區別

2021-10-04 08:21:41 字數 674 閱讀 6981

在阿根廷argentina及 澳大利亞australia所在的洲份中,列出當中的國家名字name及洲分continent。按國字名字順序排序

錯誤結果:

select name,continent from world 

where continent in (select continent from world where name ='argentina' or 'australia' ) order by name

正確結果:

select name,continent from world 

where continent in (select continent from world where name in ('argentina','australia' )) order by name

其中易錯點為:當選項結果是或關係的時候,通常思維管行為,可以用name = 'australia' or 'argentina',即name = 'australia' or 'argentina';也可以用in的關係使用區間或集合的概念來進行描述,即可表述為:name in(australia, argentina)

SQL 小白易錯點

alter場景 1 建好表後增加外來鍵約束 alter table 表名 addforeign key 欄位名 references 表名 欄位名 2 新增字段 alter table 表名 add 列名 資料格式update場景 update 表名 set 欄位名 更新後的值,可以公式表達 whe...

面試易錯點

一 char str1 abc char str2 abc char str3 abc char str4 abc str1和str2是不相同的,str3和 str4是相同的,str1和str2是儲存在堆上,str3和 str4在常量區,這兩個指標指向的是同一位址 編譯器認為p1指向的 abc 和p...

總結 易錯點

題目要求是 結尾,我使用了str 1 str 2 single line containing only marks the end of a test case.題目給的是 f1 1 f2 2 fn fn 1 fn 2 n 3 我卻從f0開始推,並且迴圈跟著從0開始了 題目可能會出現一道腦筋急轉彎...