我的语法对于create和insert是否正确 [英] Is my syntax correct for create and insert

查看:126
本文介绍了我的语法对于create和insert是否正确的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

CREATE TABLE人员



PersonID int,

LastName varchar(255),

FirstName varchar (255)





INSERT INTO人员(PersonID,LastName,FirstName)

VALUES(1, Maria,Di);

解决方案

字符字段需要在引号中如下



INSERT INTO人员(PersonID,LastName,FirstName)

VALUES(1,'Maria','Di');


您也可以使用以下



 INSERT INTO人员
选择1,'Maria','Di'

虽然提供列名是好的做法。

INSERT INTO人员(PersonID,LastName,FirstName)
选择1,'Maria','Di'


如果您正在调用此查询从前端然后将其包装在一个存储过程中,否则它将打开SQL注入。


如果您认为您的代码可能有一些错误..? ?



然后。

 1>首先运行代码
2>得到Eroor
3> 尝试自行了解错误
4> 尝试找到解决方案 你得到的错误
5>如果没有想出那么尝试在中搜索 google
6>最后请在此处或任何其他网站查找溶液


CREATE TABLE Persons
(
PersonID int,
LastName varchar(255),
FirstName varchar(255)
)

INSERT INTO Persons(PersonID , LastName, FirstName )
VALUES( 1, Maria , Di );

解决方案

Character field need to be in quotes as below

INSERT INTO Persons(PersonID , LastName, FirstName )
VALUES( 1, 'Maria' , 'Di' );


You can also use below

INSERT INTO Persons
select  1, 'Maria' , 'Di'

Although giving columns names is good practice.

INSERT INTO Persons(PersonID , LastName, FirstName )
select  1, 'Maria' , 'Di' 


If you are calling this query from front end then do wrap it within a stored procedure other wise it will open to SQL Injections.


If you think your code may have some errors..??

then.

1> Run the code first
2> Get the Eroor
3> try to understand the Error yourself
4> try to find the solution for the error which you are getting
5>if not figureout then try to find it in google
6>Lastly ask here or any other website to find the solution.


这篇关于我的语法对于create和insert是否正确的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆