sql语句:INSERT INTO `vol`.`test_number`(`ProductCode`, `ProductName`, `NumberQty`) VALUES ('tt', 'ss', 199);用SqlSugar写这个SQL语句
时间: 2023-04-10 15:01:06 浏览: 58
Sure, here's how you can write this SQL statement using SqlSugar:
var db = new SqlSugarClient(new ConnectionConfig()
{
ConnectionString = "your_connection_string_here",
DbType = DbType.MySql, // or DbType.SqlServer, DbType.Oracle, etc.
IsAutoCloseConnection = true
});
var testNumber = new TestNumber()
{
ProductCode = "tt",
ProductName = "ss",
NumberQty = 199
};
db.Insertable(testNumber).ExecuteCommand();
Note: You need to replace "your_connection_string_here" with your actual database connection string, and define the TestNumber class with the same properties as the test_number table.
相关问题
sql语句:UPDATE `vol`.`test_number` SET `ProductCode` = '33', `ProductName` = '1', `NumberQty` = 0 WHERE `id` = 3; 用SqlSugar写这个SQL语句
可以使用以下代码:
var db = new SqlSugarClient(new ConnectionConfig()
{
ConnectionString = "your connection string",
DbType = DbType.MySql,
IsAutoCloseConnection = true
});
db.Updateable<TestNumber>()
.SetColumns(t => new TestNumber()
{
ProductCode = "33",
ProductName = "1",
NumberQty = 0
})
.Where(t => t.Id == 3)
.ExecuteCommand();
function getPagedList(contractId) { var contractId = body.param.ontractId; SELECT a.id, a.conract_id contractId, a.product_id productId, a.purchase_num purchaseNum, a.purchase_price purchasePrice, a.remark, b.product_name productName, b.spec_code specCode, c.type_name typeName, d.unit_code unitCode FROM mes214820519.wms_pur_list_214820519 a, mes214820519.wms_product_214820519 b, mes214820519.wms_product_class_214820519 c, mes214820519.wms_unit_code_214820519 d WHERE a.product_id=b.id AND b.product_class_id = c.id AND b.unit_code_id=d.id `; return db.pager(sql, {contractId: contractId}) } 这段代码的错误在哪
这段代码有两个错误:
1. 在第一行中声明了 `contractId`,但在 SQL 查询语句中使用了 `body.param.ontractId`,应该改为 `body.param.contractId`。
2. SQL 查询语句的末尾多了一个反引号,应该删除它。
正确的代码应该是:
```
function getPagedList(contractId) {
var contractId = body.param.contractId;
var sql = `
SELECT
a.id,
a.conract_id contractId,
a.product_id productId,
a.purchase_num purchaseNum,
a.purchase_price purchasePrice,
a.remark,
b.product_name productName,
b.spec_code specCode,
c.type_name typeName,
d.unit_code unitCode
FROM
mes214820519.wms_pur_list_214820519 a,
mes214820519.wms_product_214820519 b,
mes214820519.wms_product_class_214820519 c,
mes214820519.wms_unit_code_214820519 d
WHERE
a.product_id=b.id
AND b.product_class_id = c.id
AND b.unit_code_id=d.id`;
return db.pager(sql, {contractId: contractId})
}
```
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)