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 6739205
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:27:35+00:00 2026-05-26T11:27:35+00:00

In MySQL, this code works fine: select f, blegg.* from blegg limit 1; +——+——+——+——+

  • 0

In MySQL, this code works fine:

select f, blegg.* from blegg limit 1;

+------+------+------+------+
| f    | f    | g    | h    |
+------+------+------+------+
|   17 |   17 |    2 |   17 |
+------+------+------+------+
1 row in set (0.00 sec)

So why does this code cause a syntax error?

select f, * from blegg limit 1;

-- * is unqualified
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near '* 
from blegg limit 1' at line 1

I’ve looked through the manual but didn’t really find anything. Why does select <field>, * ... fail where select <field>, <table>.* ... and select * ... and select *, <field> ... succeed?

  • 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-26T11:27:35+00:00Added an answer on May 26, 2026 at 11:27 am

    The MySQL manual lays all this out pretty clearly in the section on SELECT syntax:

    • A select list consisting only of a single unqualified * can be used as
      shorthand to select all columns from all tables:

      SELECT * FROM t1 INNER JOIN t2 ...
      
    • tbl_name.* can be used as a
      qualified shorthand to select all columns from the named table:

      SELECT t1.*, t2.* FROM t1 INNER JOIN t2 ...
      
    • Use of an unqualified *
      with other items in the select list may produce a parse error. To
      avoid this problem, use a qualified tbl_name.* reference

      SELECT AVG(score), t1.* FROM t1 ...
      

    The documentation seems to indicate that * by itself is only valid in the special case where it’s the only thing in the select list. However, it only says using an unqualified * with other items may produce a parse error.

    Beyond MySQL, the SQL-92 standard (old, but linkable) says as much:

    7.9  <query specification>
    
             Format
    
             <query specification> ::=
                  SELECT [ <set quantifier> ] <select list> <table expression>
    
             <select list> ::=
                    <asterisk>
                  | <select sublist> [ { <comma> <select sublist> }... ]
    
             <select sublist> ::=
                    <derived column>
                  | <qualifier> <period> <asterisk>
    
             <derived column> ::= <value expression> [ <as clause> ]
    
             <as clause> ::= [ AS ] <column name>
    

    <select list> can either be <asterisk> by itself or a “normal” select list.

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

Sidebar

Related Questions

I've got this toy code, works fine, using MySQL var r = new SimpleRepository(DB,
I have this mySQL code that connects to my server. It connects just fine:
IS this bit of code in PHP/mysql considered a stored procedure? $sql = 'SELECT
This is my code: $query = mysql_query(SELECT * FROM books ORDER BY id) or
I have this elementary query: SELECT d.description, o.code FROM order_positions AS o LEFT JOIN
I have this code in PHP $max=SELECT MAX(num) FROM info; $maxquery= mysql_query($max) or die
I have an MySQL query like this: SELECT MAX(messages.ID) as maxID, messages.from, messages.read, users.userName
Now All of this code works fine in Firfox but in IE the divs
I keep getting this error but this sql statement works fine in mysql it
I use this code to get a Blob from a MySql database and it

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.