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

  • Home
  • SEARCH
  • 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 6767523
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:57:40+00:00 2026-05-26T14:57:40+00:00

I need execute 2 select in SQLAlchemy. For example: select1 = Session.query(col1, col2, col3,

  • 0

I need execute 2 select in SQLAlchemy. For example:

select1 = Session.query(col1, col2, col3, col4).filter(...)
select2 = Session.query(col1, "", "", col4).filter(...)
result = select1.union(select2).all()

The problem is that. I don’t know how to write “” value in select2 with SQLAlchemy.

Thanks.

  • 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-26T14:57:40+00:00Added an answer on May 26, 2026 at 2:57 pm

    You probably want some combination of column, literal_column or null, which are in the sqlalchemy.sql module:

    >>> print Query((t.c.col1, 
    ...              t.c.col2, 
    ...              t.c.col3,
    ...              t.c.col4)) \
    ...   .union(
    ...       Query((t.c.col1,
    ...              sqlalchemy.sql.null().label('c2'), 
    ...              sqlalchemy.sql.literal_column('""').label('c3'),
    ...              t.c.col2))
    ...         )
    SELECT anon_1.table_col1 AS anon_1_table_col1, anon_1.table_col2 AS anon_1_table_col2, anon_1.table_col3 AS anon_1_table_col3, anon_1.table_col4 AS anon_1_table_col4 
    FROM (SELECT "table".col1 AS table_col1, "table".col2 AS table_col2, "table".col3 AS table_col3, "table".col4 AS table_col4 
    FROM "table" UNION SELECT "table".col1 AS table_col1, NULL AS c2, "" AS c3, "table".col2 AS table_col2 
    FROM "table") AS anon_1
    >>> 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to execute a SQL Query between two databases. Example: SELECT * from
I´m working with Symfony2 and I need to execute this SQL for example: select
I need to execute a select and then update some of the rows in
I need execute an SQL query in ORACLE it takes a certain amount of
I need to execute MDX query from command line (MS AS 2005). I have
I need to execute this query to find out the next auto_increment value that
I need to execute a SELECT ... from Sybase's command line tool, FSQL ,
I need to execute this Sql command (which works fine in management studio): select
I have an sqlite query that looks like this: db_rows = db_cursor.execute( SELECT *
I have a query that I need to execute against CRM. It is the

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.