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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:48:58+00:00 2026-05-26T15:48:58+00:00

This works as expected: SELECT Mike AS FName This fails with the error Query

  • 0

This works as expected:

SELECT "Mike" AS FName

This fails with the error “Query input must contain at least one table or query”:

SELECT "Mike" AS FName
UNION ALL
SELECT "John" AS FName

Is this just a quirk/limitation of the Jet/ACE database engine or am I missing something?

  • 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-26T15:48:59+00:00Added an answer on May 26, 2026 at 3:48 pm

    You didn’t overlook anything. Access’ database engine will allow a single row SELECT without a FROM data source. But if you want to UNION or UNION ALL multiple rows, you must include a FROM … even if you’re not referencing any field from that data source.

    I created a table with one row and added a check constraint to guarantee it will always have one and only one row.

    Public Sub CreateDualTable()
        Dim strSql As String
        strSql = "CREATE TABLE Dual (id COUNTER CONSTRAINT pkey PRIMARY KEY);"
        Debug.Print strSql
        CurrentProject.Connection.Execute strSql
        strSql = "INSERT INTO Dual (id) VALUES (1);"
        Debug.Print strSql
        CurrentProject.Connection.Execute strSql
    
        strSql = "ALTER TABLE Dual" & vbNewLine & _
            vbTab & "ADD CONSTRAINT there_can_be_only_one" & vbNewLine & _
            vbTab & "CHECK (" & vbNewLine & _
            vbTab & vbTab & "(SELECT Count(*) FROM Dual) = 1" & vbNewLine & _
            vbTab & vbTab & ");"
        Debug.Print strSql
        CurrentProject.Connection.Execute strSql
    End Sub
    

    That Dual table is useful for queries such as this:

    SELECT "foo" AS my_text
    FROM Dual
    UNION ALL
    SELECT "bar"
    FROM Dual;
    

    Another approach I’ve seen is to use a SELECT statement with TOP 1 or a WHERE clause which restricts the result set to a single row.

    Note check constraints were added with Jet 4 and are only available for statements executed from ADO. CurrentProject.Connection.Execute strSql works because CurrentProject.Connection is an ADO object. If you try to execute the same statement with DAO (ie CurrentDb.Execute or from the Access query designer), you will get a syntax error because DAO can’t create check constraints.

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

Sidebar

Related Questions

In a sane world, this works as expected: var array:Array = ['a','b','c']; trace(array.indexOf(array[0])); //
This method works as expected - it creates a JTree with a root node
This snippet from official website works as expected: $treeObject = Doctrine::getTable('Category')->getTree(); $rootColumnName = $treeObject->getAttribute('rootColumnName');
I have this code which compiles and works as expected: class Right {}; class
Though this works to return the right results, SELECT r.KeyColumn as '@Key', t1.Key1 as
My CSS says: option { padding: 6px; } This works as expected in Firefox
This works (prints, for example, 3 arguments): to run argv do shell script echo
This works, but is it the proper way to do it??? I have a
This works just fine: protected void txtTest_Load(object sender, EventArgs e) { if (sender is
This works fine: $.getJSON(http://localhost:59396/xxxWeb/ CarouselHandler.ashx?action=getproducts&ids= + ids, function(data) { carousel.size(allProductIDs.length); if (numberOfImagesLeftToShow < numberOfImagesToDisplay)

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.