1

I have a problem.

I'm using this query:

...
(SELECT TXTVALUE
FROM table 
WHERE
    EXTID = 2
)AS A,

(SELECT TXTVALUE 
FROM table 
WHERE
    EXTID = 4
)AS B
...

So in the end my goal is just call one's the query and create one alias per condition. Right now I have several queries(like this example up) calling the same table and I just need to have one different alias depending the condition.

Thanks in advance.

2
  • What is your question? Commented Apr 17, 2013 at 8:23
  • can you tell us what is the greater goal that you want to achieve ? i order to get the big picture Commented Apr 17, 2013 at 8:32

1 Answer 1

1

I think you might need to use UNION or UNION ALL for this:

SELECT TXTVALUE, EXTID 
FROM table 
WHERE  EXTID = 2
UNION ALL
SELECT TXTVALUE, ECTID
FROM table 
WHERE  EXTID = 4
UNION ALL
....

This will let you specify a column, so that it have a different values depending on the condition under the same column.

SELECT TXTVALUE, EXTID AS 'Types' -- For example
FROM table 
WHERE  EXTID = 2
UNION ALL
SELECT TXTVALUE, ECTID
FROM table 
WHERE  EXTID = 4
UNION ALL
....
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.