首先,我知道使用来自table_a的值更新table_b的sql语句的形式是:
甲骨文:
UPDATE table_a
SET (col1, col2) = (SELECT cola, colb
FROM table_b
WHERE table_a.key = table_b.key)
WHERE EXISTS (SELECT *
FROM table_b
WHERE table_a.key = table_b.key)
M
我使用的是Access 2007,并且有一些链接到mySQL数据库的表。我使用DAO将一条记录插入到mySQL链接表中,并尝试使用Select @@identity检索插入的PK,但select返回0。
Dim sql As String
Dim oDB As Database
Set oDB = CurrentDb
sql = "INSERT INTO Quotes ( CustomerID ) SELECT 1 AS Expr1;"
oDB.Execute sql
If oDB.RecordsAffected <> 1 Th
可以通过以下方式更改特定表的存储引擎类型:
ALTER TABLE table_name ENGINE = InnoDB;
这适用于MariaDB/MySQL安装附带的所有表,但db、host和user表除外。它引发一个(泛型)错误:
MariaDB [mysql]> ALTER TABLE db ENGINE = InnoDB;
ERROR 1025 (HY000): Error on rename of './mysql/#sql-149_24b' to './mysql/db' (errno: 168 "Unknown (generic) e
只是一个小的MySQL语句示例:
SELECT m.nameMarket nm, m.idCity idc, c.cityname cn
FROM markets m
LEFT JOIN cities c ON m.idCity = c.idCity
按预期工作。为什么两者都不能在这里工作(在Join-语句中使用Select中的别名):
SELECT m.nameMarket nm, m.idCity idc, c.cityname cn
FROM markets m
LEFT JOIN cities c ON idc = c.idCity
OR:
我想在mysql中添加触发器..。
CREATE TRIGGER mytrigger BEFORE INSERT ON table_1
FOR EACH ROW
BEGIN SET
NEW.`order` = (SELECT 1 + COALESCE((SELECT MAX(`order`) FROM `table_1`), 0));
END
我总是会犯错误:
Error
SQL query: Documentation
CREATE TRIGGER mytrigger BEFORE INSERT ON table_1
FOR EACH
ROW
BEGIN SET NEW.`order`