Results 1 to 5 of 5
  1. #1
    Join Date
    Oct 2003
    Posts
    268

    Unanswered: How do I: SELECT * FROM (1, 2, 3, 4, 5)

    Is there an easy way to do this:

    Code:
    SELECT * FROM (1, 2, 3, 4, 5)
    I want to get 5 rows with one column each. I can do this with some more complex T-SQL and table variables, but is there an easy way to do this with basic SQL?

  2. #2
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    You mean you want to split (\ normalise) a csv string?

    Something like this one:
    http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=50648

    HTH
    Testimonial:
    pootle flump
    ur codings are working excelent.

  3. #3
    Join Date
    Oct 2003
    Posts
    268
    Quote Originally Posted by pootle flump
    You mean you want to split (\ normalise) a csv string?

    Something like this one:
    http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=50648

    HTH
    No, I wanted a small list of hard coded values in a query. I figured it out. I knew this already but my mind was just moving a little slowly this morning:

    Code:
    SELECT * FROM
    	(SELECT 1 AS Value UNION
    	SELECT 2 AS Value UNION
    	SELECT 3 AS Value UNION
    	SELECT 4 AS Value UNION
    	SELECT 5 AS Value) AS ValueTable

  4. #4
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    Well if your doing that, you might as well make a numbers table
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

  5. #5
    Join Date
    Oct 2003
    Posts
    268
    Well, this query is actually part of an INSERT command that's only run once during db setup. It populates a constant configuration table.

    If this was a more general query, I would definitely make a separate table, but for this, that's just more work than necessary.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •