SQL命令来运行报告的客户数据库 - SQL command to run a report on Customers in Database

- 此内容更新于:2015-12-20
主题:

我有客户在数据库上运行报告显示名字,国家,和电话号码。我的命令,但我越来越Select语句的语法错误。这是我迄今为止。提前感谢你的帮助。

原文:

I have to run a report on Customers in Database showing Names, State, and Phone Numbers. I have the commands but I keep getting a syntax error in the Select statement. Here's what I have so far. Thanks in advance for your help.

SELECT (Last Name, First Name, State/Province, Business Phone)
FROM Customers
VALUES ('Cross', 'Sandra')
VALUES ('Speight', 'John')
VALUES ('Powell', 'Bill')
VALUES ('Stolle', 'Ryan')
VALUES ('Newman', 'Tony')
网友:你想与桑德拉十字架,约翰Speight等等?你的客户表中字段是什么?你想姓、名、州/省、businessphone所有客户或提到的只有5个人在你的查询吗?

(原文:What are you trying to do with Sandra Cross, John Speight etc? What are the fields in your customers table? Are you trying to get lastname, firstname, state/province, businessphone of all customers or only those of the 5 people mentioned in your query?)

网友:你要选择或插入……这是不明确的

(原文:You wana select OR insert ... That is half-and-half)

网友:是的,我想让lastname,firstname、州/省、业务电话只有5人。

(原文:Yes, I am trying to get the lastname, firstname, state/province, business phone only for those 5 people.)

解决方案:
试试这个。
原文:

try this.

SELECT [Last Name]
    ,[First Name]
    ,[State/Province]
    ,[Business Phone]
FROM Customers
WHERE [First Name] IN (
        'Cross'
        ,'Sandra'
        ,'Speight'
        ,'John'
        ,'Powell'
        ,'Bill'
        ,'Stolle'
        ,'Ryan'
        ,'Newman'
        ,'Tony'
        )
网友:理想情况下你不会在列名称空间。而不是使用_即Last_Name或lastName然后可以修改的列名称的选择——选择(姓)作为“姓”,

(原文:Ideally you would not have spaces in column names. instead use _ i.e. Last_Name or lastName you can then change the column name on the select like - SELECT [lastName] as 'Last Name',)

网友:你是男人!完美的工作。非常感谢。

(原文:You are the man! That worked perfectly. Thank you very much.)

网友:很高兴我能帮助,请你投票这个答案吗?

(原文:Glad I could help, could you please up vote this answer?)

网友:方括号是特定于产品的界定(没有指定dbms的问题。)ANSISQL有双引号,例如。“名字”,将与MSSQLServer。

(原文:Square bracket delimiting is product specific (and no dbms is specified in the question.) ANSI SQL has double quotes, e.g. "First Name", will work with MS SQL Server too.)