Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6233731
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T10:21:10+00:00 2026-05-24T10:21:10+00:00

Yesterday a colleague showed me the following postgres query. We were both surprised that

  • 0

Yesterday a colleague showed me the following postgres query. We were both surprised that it worked:

SELECT* FROM mytable;

Since I recently coded a parser for another language, I am trying to understand in more depth why this query “compiles” and returns the same results as SELECT * FROM mytable;.

Presumably this is recognized as a valid query because during lexical analysis, postgres reads SELECT from input as a token, and then searches for the next token, which it finds as *, and so on – is that more or less what is going on here?

Also, does the postgres lexer/parser just happen to be robust enough to understand this query, or would other databases understand a similar SELECT* query?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T10:21:10+00:00Added an answer on May 24, 2026 at 10:21 am

    Usually lexers will add characters to the current token until it finds a character that can’t belong to the current token, then it quits and starts over from where it couldn’t go on before.

    So what’s going on here is that the lexer gobbles up SELECT and sees that the next character is a * which, because it’s collecting a word, can’t belong with SELECT. So it stops, analyzes the SELECT which turns out to be a keyword, and starts over with the *, which it recognizes, and so on. It’s the same reason why you get 4 from both 2*2 and 2 * 2 in other programming languages.

    As for whether it will work on other databases, it all depends on the details of the lexical analyzer and the rules of the grammar.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Yesterday I updated to firefox 13 and I notice that this property is not
Yesterday I read some code of a colleague and came across this: class a_class
yesterday @SuperSkunk soved this little problem for me: How to return settings from an
Yesterday I had a team leader of another team say that they took a
I've picked up some code from a colleague, and in one of his methods
Yesterday and for about months I was able to push/commit. But since few hours
Yesterday I notice that some thing kept writing with 1.48M/s bursting speed every 30s
Yesterday I have been testing one single query for over hours and hours, but
Yesterday I started to develop with Phonegap. I downloaded phonegap and xCode 4.3 from
A colleague and I had a heated debate yesterday whether it is safe to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.