Select * works… But Selecting by Columns Does Not? [closed]

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



Select * works… But Selecting by Columns Does Not? [closed]



I'm getting beyond frustrated by this and I'm sure it's something simple.



I have created a number of tables and for some reason I can pull the data from all of them using Select *, but I get an "Incorrect syntax near ','." whenever I try to pull select columns.



Here's one for example:



If I run this:


select *
FROM IDs as I



The data returns as it should.



If I run this:


select
(I.EntityID,
I.EntityName,
I.LCODE)
FROM IDs as I



I get "Incorrect syntax near ','."



I have quadruple checked, all of the column names are spelled correctly and exist in the table. I've even dropped and recreated the table multiple times.



What am I missing?



For Reference I'm using Microsoft SQL Server 2016.



This question appears to be off-topic. The users who voted to close gave this specific reason:





Remove the parentheses around your select list; they don't belong there. Check this demo to see the query working after making this change.
– Tim Biegeleisen
Aug 10 at 5:24





I'd be curious to know why you added the parentheses.
– Damien_The_Unbeliever
Aug 10 at 7:39





@sccrbrg Don't try things at random. SSMS even has a query designer you can use to create your query. You can select your SELECT * FROM... query and hit Ctrl+Shift+Q to open the designer. Or go to the Query > Desing Query In Editor menu command
– Panagiotis Kanavos
Aug 10 at 7:42



SELECT * FROM...


Ctrl+Shift+Q


Query > Desing Query In Editor





Ahh that did it. I was clearly too tired. I was creating tables all day and must have gotten so used to seeing the "()" that I didn't notice the issue.
– sccrbrg
Aug 10 at 19:34




1 Answer
1



Remove the parentheses ( & ) from the select statement. These are not required.
Parentheses are used to group logic expressions in queries and for structure when working with inserts and structural changes.

Popular posts from this blog

make 2 or more post in bootsrap

Store custom data using WC_Cart add_to_cart() method in Woocommerce 3

Firebase Auth - with Email and Password - Check user already registered