Example
CREATE TABLE follows (
follower_id INTEGER NOT NULL, -- 追隨者(粉絲)
followee_id INTEGER NOT NULL, -- 被追隨者
created_at TIMESTAMP DEFAULT NOW(),
FOREIGN KEY(follower_id) REFERENCES users(id),
FOREIGN KEY(followee_id) REFERENCES users(id),
PRIMARY KEY(follower_id, followee_id) -- 避免 table 中有兩筆像 (1,2) user1 追隨 user2 的資料
);
如果重複輸入兩次 INSERT INTO follows(follower_id, followee_id) VALUES (1,2)
就會出現 ERROR 1062 (23000): Duplicate entry '1-2' for key 'PRIMARY'
錯誤
MySQL
pom.xml 添加 MyBatis 依賴
Jul 27, 2023Override the validationData() function to apply validation rules to the URL parameters. <?php namespace App\Http\Requests; use Illuminate\Foundation\Http\FormRequest; class DateRangeRequest extends FormRequest {
May 29, 2023添加欄位 ALTER TABLE myemp1 ADD salary DOUBLE(10,2); # 預設添加至表中的最後一個欄位 ALTER TABLE myemp1 ADD phone_number VARCHAR(20) FIRST; # 添加至表中的第一個欄位 ALTER TABLE myemp1 ADD email VARCHAR(45) AFTER emp_name; # 添加至 emp_name 欄位的後面 修改一個欄位:數據類型、長度、預設值
May 24, 2023參考自:MongoDB Docs > $unionWith (aggregation)stackoverflow > SQL ‘UNION ALL’ like implementation in MongoDB
Jan 6, 2023or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up