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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:41:06+00:00 2026-06-15T23:41:06+00:00

SELECT Col1 FROM Table WHERE Col2 = 63895746 ORDER BY Col FOR XML PATH,TYPE

  • 0
            SELECT Col1
    FROM Table
    WHERE Col2 = 63895746
    ORDER BY Col
    FOR XML PATH,TYPE

I dont need NULLS in the result.
i want result to be wrapped by something like
< Cols >< /Cols > even if col1 is null or not

In this example Table doesn’t contain any rows for col2 = 63895746 , so i will get an empty result set, so the type directive will make it NULL and return it

  • 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-06-15T23:41:07+00:00Added an answer on June 15, 2026 at 11:41 pm

    How about

    ;with mytmp (f1) as (
      SELECT Col1
      FROM Table
      WHERE Col1 = 123456
      ORDER BY Col1
      FOR XML PATH('col'),root('cols'),TYPE
      )
    select isnull(f1, '<cols></cols>')
    from mytmp;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

With this query SELECT least(col1, col2, col3) AS fancyTitle FROM table ORDER BY fancyTitle
I'm running a pretty standard INSERT INTO [table] (col1, col2, ...coln) select * from
I have the following query (MySQL): SELECT col1, col2 FROM database1.table ->WHERE col3 !=
When I execute a query like SELECT col1, col2, col3 FROM table , it
It doesn't seem like there's a difference between: SELECT a.col1, b.col2 FROM table a
Basically, I am trying the following: SELECT m.col1, SUM(SELECT col5 FROM table WHERE col2
How can you write the following in MYSQL? SELECT AVG(col1) FROM table WHERE DISTINCT
How do you merge these two rows? SELECT col1, col2, col3, col4 FROM table_a
That is, with a prepared statement like: select col1,...coln from table where col3 =
I have a select statement returning 5 columns: select col1,col2,col3,col4,col5 from table1; col1 col2

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.